Bizarre behavior with mutable default arguments

bukzor workitharder at gmail.com
Tue Jan 1 11:47:11 EST 2008


On Dec 30 2007, 11:01 pm, Steven D'Aprano <st... at REMOVE-THIS-
cybersource.com.au> wrote:
> On Sun, 30 Dec 2007 20:00:14 -0800, bukzor wrote:
> > I think you struck at the heart of the matter earlier when you noted
> > that this is the simplest way to declare a static variable in python.
> > Using the 'global' keyword is the other way, and is much more explicit,
> > and much more widely used. I also see this as the main use of the
> > 'notlocal' keyword to be introduced in py3k (it also fixes the example
> > given by Istvan above).
>
> There doesn't appear to be any reference to a "notlocal" keyword in
> Python 3 that I can find. Have I missed something? It sounds like an
> April Fool's gag to me. Do you have a reference to a PEP or other
> official announcement?
>
> --
> Steven

I got it slightly wrong. It's 'nonlocal':
http://www.python.org/dev/peps/pep-3104/

--Buck



More information about the Python-list mailing list