[Python-ideas] Tweaking closures and lexical scoping to include the function being defined

Devin Jeanpierre jeanpierreda at gmail.com
Thu Sep 29 22:26:44 CEST 2011


> I don't *like*
> boxing up my variables, but it still seems less offensive than a
> global statement and the resulting side effects.

How is that?

Devin

On Thu, Sep 29, 2011 at 4:24 PM, Jim Jewett <jimjjewett at gmail.com> wrote:
> On Thu, Sep 29, 2011 at 3:03 PM, Eric Snow <ericsnowcurrently at gmail.com> wrote:
>
>> The alternative is to leave nonlocal as just a simple statement, but
>> change its behavior when the name is not found inside a containing
>> function scope.  Currently that is a syntax error.
>
> Until this discussion started, I had not realized that nonlocal was
> limited to names from containing *function* scopes; I had thought that
> it would end up using the module-level globals if need be.
>
> Having it indicate a scope *closer* than all the scopes where it
> already looked but failed to find the name seems wrong.
>
> That said, my intuition may be suspect; outside examples, I have never
> used nonlocal, and work fairly hard to avoid global.  I don't *like*
> boxing up my variables, but it still seems less offensive than a
> global statement and the resulting side effects.
>
> -jJ
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
>



More information about the Python-ideas mailing list