__import__ Confusion

Benjamin Peterson benjamin at python.org
Thu Feb 12 14:22:32 EST 2009


 <scott.bronson.nelson <at> gmail.com> writes:

> 
> Can someone explain to me what's going on here?
> 
> >>> __import__('some.package.module', {}, {}, [])
> <module 'some' from 'some/__init__.py'>
> >>> __import__('some.package.module', {}, {}, [''])
> <module 'some.package.module' from 'some/package/module.py'>

As documented [1], unless fromlist is not empty, the first module is returned.
Use the solution at the end of the docs to get around this.


[1] http://docs.python.org/library/functions.html#__import__




More information about the Python-list mailing list