Derek Atkins <[EMAIL PROTECTED]> writes: > PS: I realize it might be easier now to have all your classes in > a single "Gnucash.py", but eventually I think it might be better > to separate the various classes into separate files, like Register.py, > AccountTree.py, NewAccountDialog.py, PriceDialog.py, etc. But this > doesn't have to happen right away.
Ah, Derek, one thing about this I forgot when we talked on irc ... In python, files correspond to "modules"; there's no ability to group multiple files into the same module/namespace/"package". Thus, the file NewAccountDialog.py, e.g.: class NewAccountDialog (Dialog): # ... ...is a NewAccountDialog module containing the NewAccountDialog class. It's referenced both other files as: import NewAccountDialog foo = NewAccountDialog.NewAccountDialog() If each class corresponds to a file corresponds to a module, it can be very verbose. There is a different form of the import statement, like: # from $module import $name from NewAccountDialog import NewAccountDialog foo = NewAccountDialog() But it's frowned upon. There's also: import NewAccountDialog as NAD foo = NAD.NewAccountDialog() But it not really great either. A different approach is to separate the classes into related groups such as "dialogs.py" or "register.py". Then the fully-qualified names are more manageable: import dialogs, register new_account = dialogs.NewAccountDialog() basic = register.BasicViewRegister() # ... We stay "pythonic", but the code gets factored a bit better. Hopefully this is a good middle-ground. -- ...jsled http://asynchronous.org/ - a=jsled; b=asynchronous.org; echo [EMAIL PROTECTED]
pgpjuJMHWU0KT.pgp
Description: PGP signature
_______________________________________________ gnucash-devel mailing list gnucash-devel@gnucash.org https://lists.gnucash.org/mailman/listinfo/gnucash-devel