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 mrts
Recipients georg.brandl, mrts, steven.daprano
Date 2008-11-30.12:38:20
SpamBayes Score 0.0033043856
Marked as misclassified No
Message-id <1228048702.16.0.772109295894.issue4457@psf.upfronthosting.co.za>
In-reply-to
Content
Also, the examples that clarify __import__ behaviour by Nick Coghlan
should be added:

http://mail.python.org/pipermail/python-dev/2008-November/083735.html

---

"from foo.bar import baz" ---->

<stack top> = __import__('foo.bar', globals(), locals(), ['baz'], -1)
baz = <stack top>.baz

When there are multiple names being imported or an 'as' clause is
involved, I hope the reasons for doing it this way become more obvious:

"from foo.bar import baz, bob" ---->

<stack top> = __import__('foo.bar', globals(), locals(), ['baz', 'bob'], -1)
baz = <stack top>.baz
bob = <stack top>.bob

"from foo.bar import baz as bob" ---->

<stack top> = __import__('foo.bar', globals(), locals(), ['baz', 'bob'], -1)
bob = <stack top>.baz

---

And the "winning idiom" by Hrvoje Niksic for accessing module 'z', given
name hierarchy 'x.y.z' should be documented as well:

>>> import sys
>>> __import__('x.y.z')
>>> mod = sys.modules['x.y.z']
History
Date User Action Args
2008-11-30 12:38:22mrtssetrecipients: + mrts, georg.brandl, steven.daprano
2008-11-30 12:38:22mrtssetmessageid: <1228048702.16.0.772109295894.issue4457@psf.upfronthosting.co.za>
2008-11-30 12:38:21mrtslinkissue4457 messages
2008-11-30 12:38:20mrtscreate