module variable scope
Stefan Quandt
squan at web.de
Tue Oct 28 08:37:05 EST 2003
I want to set a modules global variable from outside like this:
<begin a.py>
v = None
def setv( x ): v = x
def getv(): return v
<end a.py>
<begin b.py>
from a import v, setv, getv
print v
setv( 'hello' )
print print getv()
<end b.py>
Running b.py gives:
None
None
I expected variable v to be changed by calling setv() but it is not.
Who can explain this?
Thanks
Stefan
More information about the Python-list
mailing list