The global variable does not 'save' after the function is done being executed. You can run the code below and see the debug output.
Main file:
from GlobalTest import *
def init():
#call that function, should set Mode2D to True
set2DMode(True)
#define it as a global
global Mode2D
#see what the value is set to now, which is not what I set it to for an unknown reason
print("Mode:",Mode2D)
init()
GlobalTest:
Mode2D = False
def set2DMode(mode):
#define it as global so it uses the one above
global Mode2D
#set the GLOBAL variable to the argument
Mode2D = mode
#output of what it thinks it is, which is as expected
print("local var mode =",mode)
print("Mode2D =", Mode2D)
What I expect:
local var mode = True
Mode2D = True
Mode: True
Result I get:
local var mode = True
Mode2D = True
Mode: False