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

Georg Brandl g.brandl at gmx.net
Fri May 6 09:44:02 CEST 2011


On 06.05.2011 09:20, dag.odenhall at gmail.com wrote:
> On 6 May 2011 00:24, Brendan Moloney <moloney at ohsu.edu> wrote:
>> Benjamin Peterson [benjamin at python.org] wrote:
>>> import * is generally frowned upon, so encouraging its use by extending it is
>>> not a good idea.
>>
>> Well it is frowned upon precisely because it pollutes the current namespace. This change would eliminate that issue.
> 
> I like this idea, except it's inconsistent with from-import-star, the
> latter which does *not* get you sub-packages or modules.

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``.

Georg




More information about the Python-ideas mailing list