Python global closure scoping oddity
Beware closuring in global variables.
In the above example, the reference the local world
was closured in to world_knower
, and the value was changed after the world_knower
declaration.
What if we use the global
keyword to let python know we want to use the global version of this variable?
Yikes, the inner function still uses the outer functions local reference. I guess if we truly want to ignore the local reference, we need to declare that world
is global in the inner function.