[Python-ideas] Tweaking closures and lexical scoping to include the function being defined
Nick Coghlan
ncoghlan at gmail.com
Tue Sep 27 21:18:24 CEST 2011
On Tue, Sep 27, 2011 at 2:46 PM, Paul Moore <p.f.moore at gmail.com> wrote:
>> - it is suggestive of the fact that the initialisation expression is
>> not evaluated in the local scope
>
> Not really (at least not to me). Nonlocal is associated (by its
> position) with the VAR, not with the EXPR. If anything, it says
> "assign this local EXPR to the nonlocal VAR" which implies it's
> equivalent to "nonlocal VAR; VAR = EXPR".
That comment gets us back to the "nonlocal EXPR as VAR" syntax. That
one looks really odd when used with constants though (what's a
nonlocal zero?), and I'm not sure the parser could handle it.
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-ideas
mailing list