[Python-ideas] Allow 'import star' with namespaces

Nick Coghlan ncoghlan at gmail.com
Wed May 11 14:21:35 CEST 2011


On Tue, May 10, 2011 at 4:55 AM, Eric Snow <ericsnowcurrently at gmail.com> wrote:
> So the sub-module name binding mechanism is simply to bind the package
> module and then bind the submodules to it.  However, "import temp.mod as
> something_else" and "from temp import mod" don't do this, which makes sense.

Not quite - both of the latter options change the name binding
behaviour in the *current* module, but temp.mod will be set to the
imported module regardless. It's part of the import process, whereas
the namebinding in the current module happens later (the underlying
complexity of all this is why importlib.import_module() was added to
replace direct invocation of __import__(). The latter has quite a
weird signature in order to support the various incarnations of the
import statement).

Cheers,
Nick.

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



More information about the Python-ideas mailing list