I have two modules and I'm trying to modify a global variable in the first module from the second module.
app.py
:
import time
glob=0;
def setval(val):
global glob
glob = val
print "glob = "+glob
def bau():
while(1):
if(glob):
print"glob is set"
else:
print"glob is unset"
time.sleep(1)
bau()
start.py
:
from app import setval
app.setval(1)
I not able to understand why in start.py
the full content of app.py
is included and not only the function that I want.
Second I don't understand why by running the first app.py
and then start.py
, that start.py
does not modify the value of the global variable in app.