Where to import modules?

Peter Hansen peter at engcorp.com
Thu Oct 2 13:39:45 EDT 2003


Mel Wilson wrote:
> 
> In article <3F74375A.F9D4B0EB at engcorp.com>,
> Peter Hansen <peter at engcorp.com> wrote:
> >I would not bother putting imports that are rarely used in only the
> >functions which need them *unless* I had a really large module which
> >took a long time to import and I was actually having problems with
> >startup time for the application.
> 
>    I can see a case for
> 
>         if __name__ == '__main__':
>             import getopt
> ...
> 
> and even sys (for sys.argv), if the rest of the module
> doesn't deal with sys.  But that's because running as the
> main module instead of a library module is a big change in
> operating environment and rationale.

Agreed!




More information about the Python-list mailing list