problems with class initiation
nperkins7 at home.com
Mon Jul 2 03:20:16 CEST 2001
You could pass a reference to your 'prefs' to the constructor of 'Second'..
self.prefs = prefs
Now class Second keeps it's own reference to the 'prefs' object, instead of
relying on using some other binding to the same object.
self.prefs = Preferences()
self.fns = 
second = Second(self.prefs)
# depending what you wanted, either of:
self.fns.append(second.init_fn) # appends the function itself,
self.fns.append(second.init_fn()) # calls the fn, and appends the
if __name__ == '__main__':
app = Main()
Since you have a list called fns, I wonder whether you intend to have a list
of functions, in which case, the first of the two commented lines does what
On a more general note, it looks like you are using classes for everything,
where some of these things might be better off as simple functions. Unlike
java, not everything has to be a class. (for starters, class 'main' should
probably be just a function: def main(): ...
More information about the Python-list