[issue4098] surprised by default list parameter

2008-10-10 Thread Amaury Forgeot d'Arc
Amaury Forgeot d'Arc <[EMAIL PROTECTED]> added the comment: Yes, the default value expression could be evaluated each time the function is called without the parameter. But it would be another language. Default values are computed once, and this is a Python feature. It can be useful, for example

[issue4098] surprised by default list parameter

2008-10-10 Thread Torsten Rottmann
Torsten Rottmann <[EMAIL PROTECTED]> added the comment: OK. I've read the Python Reference Manual 7.6 "Function Definition". It "explains" why this happens. BUT: Why can`t the compiler make a copy of the default object, if it's mutable (e.g. a list)? This can't be that difficult. __

[issue4098] surprised by default list parameter

2008-10-10 Thread Ulrich Eckhardt
Ulrich Eckhardt <[EMAIL PROTECTED]> added the comment: http://effbot.org/pyfaq/why-are-default-values-shared-between-objects.htm The same recently cropped up on the users mailinglist under the topic "default value in __init__". -- nosy: +eckhardt ___

[issue4098] surprised by default list parameter

2008-10-10 Thread Torsten Rottmann
New submission from Torsten Rottmann <[EMAIL PROTECTED]>: The attached file produced the following result: __ trott$ python2.5 p6.py [] [1234] __ I expected both times the empty list since the print statement prints just a defaulted parameter ("e") which