dogtail test suite test harness
Josh Sled
jsled at asynchronous.org
Wed Jul 25 16:19:29 EDT 2007
Derek Atkins <warlord at MIT.EDU> 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 ${a}@${b}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 188 bytes
Desc: not available
Url : http://lists.gnucash.org/pipermail/gnucash-devel/attachments/20070725/41ec3a83/attachment.bin
More information about the gnucash-devel
mailing list