Let a.py :
def foo(): global spam spam = 42 return 'this'
On the console, if I just import a , I understand everything:
>>> import a >>> a.foo() 'this' >>> a.spam 42
However, if I do a less popular thing and ...
>>> from a import * >>> foo() 'this' >>> spam Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'spam' is not defined >>> a.spam Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'a' is not defined
I read opinions about why people don't like β from module import * β in terms of namespace, but I canβt find anything about this, and to be honest, I realized that this is the problem that I ran into an accident.
User 4574
source share