Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #36059
| From | Kene Meniru <Kene.Meniru@illom.org> |
|---|---|
| Subject | Re: Can't seem to start on this |
| Followup-To | gmane.comp.python.general |
| Date | 2013-01-03 09:06 -0500 |
| Organization | illom.org |
| References | <kc31l4$27v$1@ger.gmane.org> <20130103082031.73a5b842@dilbert> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.37.1357222033.2939.python-list@python.org> (permalink) |
Followups directed to: gmane.comp.python.general
D'Arcy J.M. Cain wrote: > > OK, "global variables" is the clue that you need to rethink this. Try > to stay away from global variables as much as possible except for maybe > some simple setup variables within the same file. Consider something > like this instead. > The global variable is not part of the LinearMark object. It will be used by ALL objects created. I understand the uneasiness with this so maybe I will make it a function so it will be set with something like: SnapSize(num) > In file B: > > class TopClass(object): > def __init__(self, snap_size, var1 = None, var2 = None): > self.snap_size = snap_size > self.var1 = var1 > if var2 is None: self.var2 = 7 > self.var3 = "GO" > self.var4 = "Static string" > > *add class methods here* > > In file A: > > class MyClass(TopClass): > def __init__(self, var1): > TopClass.__init__(self, 10, var1, 8) > self.var3 = "STOP" > > x = MyClass(42) > x.var4 = "Not so static after all" > As I mentioned, the file "A" can be considered a scene file. I do not want the user to have to create classes there. I apologize for the lack of code. I will soon have some python code so my future questions will have some examples. Thanks for the comments.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Can't seem to start on this Kene Meniru <Kene.Meniru@illom.org> - 2013-01-03 09:06 -0500
csiph-web