Mart Sõmermaa <[EMAIL PROTECTED]> added the comment: 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'] ---------- nosy: +mrts _______________________________________ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue4457> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com