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

Chris Rebert pyideas at rebertia.com
Wed Sep 28 05:47:52 CEST 2011

On Tue, Sep 27, 2011 at 3:23 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> On Sep 27, 2011 3:55 PM, "Nick Coghlan" <ncoghlan at gmail.com> wrote:
>> On Tue, Sep 27, 2011 at 3:50 PM, Gisle Aas <gisle at activestate.com> wrote:
>>> On Sep 27, 2011, at 6:12 , Guido van Rossum wrote:
>>>> "our" is something in Perl, right?
>>> That's right, and "our" is similar to Python's "global".  Perl went with
>>> "state" as the keyword the concept described in this thread.
>>>   state $foo = 1;
>> I actually like that as a term for the concept (I've certainly used it
>> in my own descriptions in this very thread), but I shudder to think
>> how much code would have to change if we made 'state' a keyword :P
> Hmm...  'local', 'statelocal', 'nonlocal', 'global', 'builtin'?

I'll just toss the following variants out there. They tend to read
nicely if one assumes the syntax "<keyword> <expr> as <identifier>",
though "<keyword> <identifier> = <expr>" would also work for some of

* Emphasizing that the eval happens in the outer scope:
          take, grab, seize, capture
* Emphasizing that the var/val persists between calls:
          hold, keep, stow, retain

I <3 Thesauri.

More information about the Python-ideas mailing list