[Python-Dev] __import__ docs follow-up

Nick Coghlan ncoghlan at gmail.com
Fri Dec 5 23:21:55 CET 2008


Georg Brandl wrote:
> Hi,
> 
> as a follow-up to the thread a few days ago, and the bug report, I've
> rewritten most of the __import__ docs.  I've attached the suggested patch
> to the issue <http://bugs.python.org/issue4457>.
> 
> I'd be glad for reviews. Also, I'd like to ask about opinions if this
> "winning idiom" (as a bug comment states) should be in it, instead of
> the getattr() helper function:
> 
>>>> import sys
>>>> __import__('x.y.z')
>>>> mod = sys.modules['x.y.z']

That way is a lot cleaner than other mechanisms I've seen (including the
current mechanism in the docs). Making that the recommended way of doing
a dynamic import seems like a good idea to me.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------


More information about the Python-Dev mailing list