Questions about multiple import's.

David Bolen db3l at fitlinxx.com
Thu Sep 7 22:18:18 EDT 2000


Steve Juranich <sjuranic at condor.ee.washington.edu> writes:

> I've read the docs on this, and it's still not entirely clear to me. In one
> module, I've imported the re, os, and sys modules.  Now in a parent module,
> I will also need som funtionality from re, sys, and os.  Does it severely
> hinder performance to re-import the 3 system modules into the parent
> namespace, or should I just resolve myself to getting at the functions by
> tacking on an additional "name." construnction (e.g.,
> child.re.string.strip())?

Just go ahead and import it in each module that uses it.  The
interpreter will really only load the module once, so any further
imports are low overhead, just establishing a label for that module in
the local namespace at the point of import.

Currently loaded modules can be tracked in the sys.modules dictionary.

--
-- David
-- 
/-----------------------------------------------------------------------\
 \               David Bolen            \   E-mail: db3l at fitlinxx.com  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \
\-----------------------------------------------------------------------/



More information about the Python-list mailing list