On Dec 23, 7:10 am, alex23 <wuwe...@gmail.com> wrote: > On Dec 22, 6:51 pm, Rolf Camps <r...@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. [Just my rephrasing of what Ian is saying] -- http://mail.python.org/mailman/listinfo/python-list