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

Georg Brandl g.brandl at gmx.net
Sat May 7 18:12:06 CEST 2011


On 06.05.2011 21:49, Brendan Moloney wrote:
> 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.

Right -- I forgot about __all__.

Georg




More information about the Python-ideas mailing list