Import confusion
Kristian Ovaska
kristian.ovaska at helsinki.fi
Sat Apr 7 07:24:39 EDT 2001
----- m1.py -----
from m2 import *
setX(10)
print x
----- /m1.py ----
----- m2.py -----
x = 0
def setX(y):
global x
x = y
----- /m2.py ----
When I run m1, it prints 0. Why doesn't it print 10?
----- m1b.py -----
import m2
m2.setX(10)
print m2.x
----- /m1b.py ----
Now, this prints 10. I'm confused. Could someone explain what's going
on?
--
Kristian Ovaska <kristian.ovaska at helsinki.fi>
More information about the Python-list
mailing list