A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2011-April/110937.html below:

[Python-Dev] Allowing import star with namespaces

[Python-Dev] Allowing import star with namespaces [Python-Dev] Allowing import star with namespacesSteven D'Aprano steve at pearwood.info
Tue Apr 26 19:48:13 CEST 2011
Brendan Moloney wrote:
> We all know that doing:
> 
>> from pkg import *
> 
> is bad because it obliterates the 'pkg' namespace. So why not allow something like:

I don't quite know what you mean by obliterating the pkg namespace, but 
if my guess is correct, you're wrong. One of the problems with import * 
is that it (potentially) obliterates the caller's namespace, not pkg. 
That is, if you have a function spam(), and you do "from module import 
*", and module also has spam(), it blows away your function. The pkg 
namespace isn't touched -- it's just unavailable to the caller.

  >> import pkg.*
> 
> This would still be helpful for interactive sessions while keeping namespaces around.

I don't understand what the difference between that and just "import 
pkg" would be.


By the way, this sort of question should probably go to the python-ideas 
mailing list for any extended discussion.



-- 
Steven
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4