I switch program mode by modifying a global value in my main module.
The change is reflected in following function calls originating inside that module, but not when other modules call the same functions.
Is the main module using an old/external/duplicated value when function calls come from the outside?
main_module.py
import second_module
mode = 1
def print_mode():
print 'Mode: ' + str(mode)
if __name__ == "__main__":
print_mode()
mode = 2
print_mode()
second_module.problem()
second_module.py
from main_module import print_mode
def problem():
print_mode()
output
$ python main_module.py
Mode: 1
Mode: 2
Mode: 1