[Python-ideas] fixing mutable default argument values

Chris Rebert cvrebert at gmail.com
Wed Jan 31 00:08:53 CET 2007

On 1/30/07, Roman Susi <rnd at onego.ru> wrote:
> The proposal (as it seems to me) wants to make change to the language
> inconsistent with nature dynamic semantics. Its like put implicit:
>     do this
> else:
>     do that
> for the same line of code (def statement's first line).

No, my proto-PEP has never contained semantics like that anywhere in it.

> > Well, it's good to be clear on where the disagreements lie. However I'm
> > not yet ready to let it rest at that without some more arguments.
> >
> > As Chris pointed out in his first mail, this 'wart' is mentioned on
> > several lists of python misfeatures: [0][1][2]. I'd like to add to this
> > that even the python documentation finds this issue severe enough to
> > issue  an "Important warning"[4].
> >
> > It seems clear that this behaviour is a gotcha, at least for newbies.
> > This  could be excused if there is a good reason to spend the additional
> > time  learning this behaviour, but some of the links state, and my
> But as somebody already said the alternative is even worse...
> Its quite easier to mention 3-5 Python warts up front to newbies than to
> introduce subtle exception for semantics and noise words such as "new"
> which do not have any other use elsewhere.

Sidenote: There could instead be a new keyword 'once' to indicate the
old semantics. I think the PEP related to adding a switch statement
proposes the same keyword for a similar use.

- Chris Rebert

More information about the Python-ideas mailing list