In article <[EMAIL PROTECTED]>,
 Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:

> In <[EMAIL PROTECTED]>, Lou Pecora wrote:
> 
> > *In mod1.py
> > 
> > import mymodule
> > 
> > *In mod2.py
> > 
> > import mymodule
> > 
> > *In mod3.py
> > 
> > import mymodule as MM
> > 
> > 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?
> 
> Yes, that's correct.
> 
> Ciao,
>       Marc 'BlackJack' Rintsch

Thank you.

A further confusion (if I may):

I have noticed that using from xxx import * can lead to problems when 
trying to access variables in the xxx module.

E.g.

-- File f2.py

imvar=1

def prn():
   print imvar

-- File junk.py

from f2 import *
prn()
imvar=2
prn()

-- Running junk.py gives the output:

1
1

Not what I would expect which is,

1
2

Namespaces get confusing.  I have begun to switch to using 'import f2 
as' which gives the 2nd expected result. Safer, but still a bit puzzling.

-- Lou Pecora  (my views are my own) REMOVE THIS to email me.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to