Is this right? Multiple imports of same module.

Lou Pecora pecora at anvil.nrl.navy.mil
Sat Mar 10 12:22:50 EST 2007


In article <mailman.4878.1173485909.32031.python-list at python.org>,
 Ben Finney <bignose+hates-spam at benfinney.id.au> wrote:

> Lou Pecora <pecora at anvil.nrl.navy.mil> writes:
> 
> > ['import mymodule' in three separate modules]
> >
> > Then mymodule is imported only once, but each module has access to
> > it through the module name (mod1 and mod2) and the alias MM (mod3).
> > Is that right?
> 
> Not quite. The module is imported three times, and is assigned to
> three different namespaces; but the code in the module is executed
> only once, the first time it is imported. Each subsequent import skips
> the "execute the code" step.

Thanks.  That's clear.

-- Lou Pecora  (my views are my own) REMOVE THIS to email me.



More information about the Python-list mailing list