Where to import modules?

JCM joshway_without_spam at myway.com
Fri Sep 26 09:33:49 EDT 2003


Peter Hansen <peter at engcorp.com> wrote:
...

> Basically doing this is an optimization, and you shouldn't be optimizing
> before the program is working, and you shouldn't be optimizing without
> a real need for it.  (That is, just because it's a little faster doesn't
> mean it's worth doing.)

Aside from being an optimization, it's also good for documentation.
If you see an import at the top of a file it might not be immediately
clear how or why the module is being used.  It's similar reasoning to
why you might define variables in the narrowest scope posible.




More information about the Python-list mailing list