Nested module import clutters package namespace?
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Thu Feb 28 19:16:20 EST 2008
En Thu, 28 Feb 2008 11:00:08 -0200, Dr. Rüdiger Kupper
<ruediger.kupper at honda-ri.de> escribió:
> I'd be grateful for help with a problem of package and module
> namespaces. The behaviour I observe is unexpected (to me), and I
> couldn't find the answer in the docs, the tutorial, or the mailing
> list archive. So here we go:
>
> I have a package named 'pack'. Apart from the '__init__.py' file the
> directory contains two modules 'x.py' and 'y.py':
>
> pack/
> __init__.py
> x.py
> y.py
>
> ==== __init__.py ====
> print "pack: Here is pack."
> print "pack: I now assign y='hello'."
> y="hello"
> print "pack: My y is now:", repr(y)
> print "pack: I now 'import x' which in turn does 'import y as q'."
> import x
> print "pack: My y is now:", repr(y)
> print "pack: Why?"
> =====================
>
> ==== x.py ===========
> print ' x: Here is x.'
> print " x: I now 'import y as q'."
> import y as q
> =====================
>
> ==== y.py ===========
> print ' y: Here is y.'
> =====================
Looks like a bug to me - or perhaps someone who actually understands how
import works could explain it?
http://bugs.python.org/
--
Gabriel Genellina
More information about the Python-list
mailing list