
Sept. 26, 2011
4:45 a.m.
On 26 September 2011 12:34, Nick Coghlan <ncoghlan@gmail.com> wrote:
On Mon, Sep 26, 2011 at 2:56 AM, Greg Ewing <greg.ewing@canterbury.ac.nz> wrote:
So, your proposed use of 'nonlocal' would actually be declaring a name to be *local*. That strikes me as weird and perverse.
Ah, but it *wouldn't* be local, that's the point - it would be stored on the function rather than on the frame, and hence be shared across invocations.
Hmm, its lifetime is non-local, but the visibility is still local. My instincts associate the word "(non-)local" with visibility rather than lifetime. If you want a bikeshed to colour in, maybe "persistent" is a better keyword for this: def counter(): persistent n as 1 print(n) n += 1 Paul.