[Python-ideas] Tweaking closures and lexical scoping to include the function being defined
ethan at stoneleaf.us
Mon Sep 26 21:08:48 CEST 2011
Bruce Leban wrote:
> The keyword nonlocal means that this binding is not local to this scope
> but can be found up the call stack. In contrast, your usage means the
> binding is local to this function, created before the function is called
> the first time and shared with all calls to this function. Those are
> orthogonal scopes.
Another way of looking at this is that the keyword nonlocal means the
name is bound in a surrounding scope; which is still true with Nick's
proposal. Nick's proposal has the added benefit of fast lookup.
nonlocal also carries with it the implication of persistence, which
Nick's proposal also has (indeed, it's one of the main points).
More information about the Python-ideas