how does import work ?
Alex Martelli
aleax at aleax.it
Wed Nov 20 09:41:21 EST 2002
Michele Simionato wrote:
...
> Suppose now I import ONLY the function f2, but not f1:
>
>>>> from f1f2 import f2
That's basically equivalent to:
import f1f2
f2 = f1f2.f2
del f1f2
except that if you already had an f1f2 identifier it's not disturbed.
> therefore Python has imported f1 too, but is some hidden way, since
> f1 is not in the current namespace dictionary:
Of course not, but it's in sys.modules['f1f2'] 's namespace, right
where it should be.
> This behavior is quite confusing to me, somebody can explain what is
> happening ?
HTH...
Alex
More information about the Python-list
mailing list