This is apparently the same question as this (S.O. didn't find it until later). Am investigating duping. However, the title line alone makes this a useful question.
In the following (two) chunks of code, why don't I get the updated value when I import?
Two files: import.py and export.py Here is export.py:
i=12345
def change_i(x):
global i
i=x
print "export changed i to {0}".format(repr(i))
Here is import.py:
from export import i, change_i
print "Import gets i={0}".format(repr(i))
change_i(5)
print "Import has i={0}".format(repr(i))
Here is the result:
> python import.py
Import gets i=12345
export changed i to 5
Import has i=12345
Why isn't import.py getting the new value 5????