If the title is a bit cryptic (I have no idea how to put my issue in one title) here the explanation.
I have a global variable
ex = False
orig = id(ex)
Then, I have two functions:
def start(test):
print("Start")
global ex
while True:
if id(ex) == orig:
print("same")
else:
print(orig)
print(id(ex))
def end(test):
print("End")
global ex
ex = True
while True:
if id(ex) == orig:
print("same")
else:
print(orig)
print(id(ex))
When I enter the "end-function" the id of "ex" in the function is not the same as the original id. So, they are basically two different variables.
I do not understand why this happens. I mean, I know that it happens because I do set "ex = True" (because if I skip this line, the id is the same). But I do not understand why. I thought the idea of global keyword is exactly to make it possible to set global variables inside a function. Using global variables in a function