import statement convention

Diez B. Roggisch deets at nospam.web.de
Tue Apr 8 17:53:57 CEST 2008


MartinRinehart at gmail.com wrote:

> By convention, I've read, your module begins with its import
> statements. Is this always sensible?
> 
> 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?
> 
> Can we do a better job with a thoughtful rewrite of this convention?

Or you could write explicit tests in explicit modules instead of mingling
both aspects together in one file. Would that be a thoughtful rewrite of
your code?

Diez



More information about the Python-list mailing list