what does 'a=b=c=[]' do

Ethan Furman ethan at stoneleaf.us
Fri Dec 23 03:49:45 EST 2011


rusi wrote:
> On Dec 23, 7:10 am, alex23 <wuwe... at gmail.com> wrote:
>> On Dec 22, 6:51 pm, Rolf Camps <r... at roce.be> wrote:
>>
>>> I'm afraid it's dangerous to encourage the use of '[]' as assignment to
>>> a parameter in a function definition. If you use the function several
>>> times 'default' always points to the same list.
 >>
>> I appreciate the concern, but adding a default argument guard would
>> not only obscure the code. It's irrelevant, as you recognise, because
>> no matter what, it's going to make copies of the default argument.
>>
>> You know what the say about foolish consistencies :)
> 
> Programming languages can have bugs as much as programs can.
> A classic example is the precedence table of C which Kernighan or
> Ritchie (dont remember which) admitted was wrong.
> 
> Likewise function arguments that default to mutable entities is a
> known gotcha of python which is best treated as a bug in python. It
> should be avoided with the suitable additional circumspection that a
> language bug deserves over a program bug.

That is the most ridiculous thing I have heard in a while.  Mutable 
default arguments are *not* a bug in Python.

Reminds me of a bug report a couple years back claiming multiple 
inheritence was a bug and asking it to be removed.

~Ethan~



More information about the Python-list mailing list