Hi all,
I've a question, essentially about the import statement. Suppose I have
two python files, a.py and b.py:
a.py
----
flag = True
def getFlag():
return flag
b.py
----
from a import *
now, in the interpreter:
>>> import b
>>> b.flag
True
>>> b.flag=False
>>> b.flag
False
>>> b.getFlag()
True
this is probably related to namespaces? I find it very confusing, because
after the import, b _does_ have an attribute called 'flag' (try dir(b)),
which has the value that was assigned to it in a.py. (i.e. the second
statement in the interpreter does not inject a new variable 'flag' into
b.) however, modifications to 'flag' are not 'seen' by functions defined
in a.py, called from b (i.e. b.getFlag()).
could someone explain what is happening here?
thanks,
Joris van Zwieten
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor