when is a != foo.a?
Chaz Ginger
cginboston at hotmail.com
Mon Aug 28 07:13:20 EDT 2006
I am somewhat new to Python (last year). As such I encounter little
"gotchas" all the time. I am wondering is someone can explain this to me:
If have three simple files:
a.py ---------------------
foo = None
def a(b):
global foo
foo = b
b.py ----------------------
from a import foo
def b(): print foo
c.py ----------------------
import a
from b import b
print 'per a.a() ',a.foo
a.a(245)
print 'expect 245 ', a.foo
b()
If I run 'python c.py' I get the following printed out:
per a.a() None
expect 245 245
None
That surprised me. If I change b.py to
import a
def b(): print a.foo
I get the following (which is what I expected originally):
per a.a() None
expect 245 245
245
Can someone explain what is really going on here?
TIA,
Chaz
More information about the Python-list
mailing list