[Python-ideas] Tweaking closures and lexical scoping to include the function being defined
greg.ewing at canterbury.ac.nz
Tue Sep 27 07:15:28 CEST 2011
Nick Coghlan wrote:
> Now, the use of 'nonlocal' in the inner function has *changed the
> lifecycle* of x. It is now a nonlocal variable - it survives beyond
> the execution of the function that defines it.
Yes, but that's just a logical consequence of the fact
that it's *visible* from the inner function, together
with the fact that Python never throws anything away
while it's still accessible. Visibility is still the
primary concept attached to 'nonlocal'.
More information about the Python-ideas