This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author barry
Recipients barry, brett.cannon
Date 2015-04-22.17:20:15
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1429723215.79.0.516170111156.issue24029@psf.upfronthosting.co.za>
In-reply-to
Content
From Guido:

It's definitely intentional, and it's fundamental to the package import
design. We've had many implementations of package import (remember "ni.py"?
last seen as "knee.py") and it was always there, because this is done as
part of *submodule loading*. For better or for worse (and because I didn't
know Java at the time :-) Python declares that if you write `import
foo.bar` then later in your code you can use `foo.bar` to reference to the
bar submodule of package foo. And the way this is done is to make each
submodule an attribute of its parent package. This is done when the
submodule is first loaded, and because of the strict separation between
loading and importing, it is done no matter what form of import was used to
load bar.

I guess another thing to realize is that the globals of __init__.py are
also the attribute namespace of the package.

I'm not surprised it's in the reference manual -- that hasn't been updated
thoroughly in ages, and I sometimes cry when I see it. :-) So please do
clarify this for the benefit of future implementers.
History
Date User Action Args
2015-04-22 17:20:15barrysetrecipients: + barry, brett.cannon
2015-04-22 17:20:15barrysetmessageid: <1429723215.79.0.516170111156.issue24029@psf.upfronthosting.co.za>
2015-04-22 17:20:15barrylinkissue24029 messages
2015-04-22 17:20:15barrycreate