Recently I caught a bug in my code which wondered me enough. The main problem is that the code below works:
def test():
print(memory)
if __name__ == "__main__":
memory = 1
test()
It would be clear if memory
were defined at the top of file but this seems like breaking all the scope rules for me. However there must be some reason.