I have 2 python scripts. I am trying to access value of global variable from one.py into two.py.
Here is my code.
one.py
import two
myvar = False
def fun():
global myvar
myvar = True
two.use_me()
two.py
import one
print "from two: ", one.myvar
def use_me():
print "This is used in one.py"
I am getting this error:
$ python two.py
from two:
Traceback (most recent call last):
File "two.py", line 1, in <module>
import one
File "one.py", line 1, in <module>
import two
File "two.py", line 2, in <module>
print "from two: ", one.myvar
AttributeError: 'module' object has no attribute 'myvar'
Not sure what I am missing here. Can someone please help?