import statement convention
Ben Finney
bignose+hates-spam at benfinney.id.au
Tue Apr 8 21:20:41 EDT 2008
MartinRinehart at gmail.com writes:
> By convention, I've read, your module begins with its import
> statements. Is this always sensible?
There are exceptions, but the benefits are great: It's very easy to
see what this module requires, without needing to execute it.
> I put imports that are needed for testing in the test code at the
> end of the module. If only a bit of the module has a visual
> interface, why pollute the global namespace with 'from Tkinter
> import *'? Wouldn't that be better done in a separate class or
> function?
If your test code requires the Tkinter module but the rest of the code
doesn't, why pollute the functional module with such test code? Move
it to a separate unit test module.
--
\ “Never do anything against conscience even if the state demands |
`\ it.” —Albert Einstein |
_o__) |
Ben Finney
More information about the Python-list
mailing list