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

Brendan Moloney moloney at ohsu.edu
Fri May 6 21:49:08 CEST 2011


dag.odenhall at gmail.com wrote:
> I like this idea, except it's inconsistent with from-import-star, the
> latter which does *not* get you sub-packages or modules.

Georg Brandl [g.brandl at gmx.net] wrote:
> And that's for a reason: it's not easy (I think it's even impossible, because
> for example individual submodules can change __path__) to determine all
> importable submodules of a package.

> So ``import pkg.*`` would not have any behavior other than ``import pkg``.

When I said all _public_ sub-packages and modules I was referring to those listed in the  __all__ attribute of 'pkg'.  Thus it would behave in the exact same way as from-import-star except you don't pollute the current namespace.

Brendan



More information about the Python-ideas mailing list