Skip to content Skip to sidebar Skip to footer

Change Global Variable In Python In Another Thread

I want change global variable in module1.py by module2.py. module1.py #!/usr/bin/env python import threading import module2 as module22 import time values=True def main(): prin

Solution 1:

You need to declare values as global, if you dont do this, the variable is handled as new local variable.

def change():
  global values
  print "change"
  values=False

Post a Comment for "Change Global Variable In Python In Another Thread"