Question: Importing the same module under different names

Andreas Jung andreas at zope.com
Mon Jun 3 13:52:58 EDT 2002


Usually Python imports a module 'foo' only once when one uses
multiple 'import foo' statements. However Python load the 
module when one uses packages e.g.

packages/__init.py
        /foo.py


When PYTHONPATH is set to the 'packages' directory then

import foo
import packages.foo 

or

import foo
from packages import foo

loads the foo module twice. How does Python determine in this case
to load the module or not?

Andreas 








More information about the Python-list mailing list