[issue2561] Instance remembers old values from former life
Georg Brandl
report at bugs.python.org
Sun Apr 6 10:30:51 CEST 2008
Georg Brandl <georg at python.org> added the comment:
Yes, this is expected. Default values are only evaluated once, at
function creation time. If you need to have a mutable default argument
that is assigned to something and changed, use something like this:
def f(arg=None):
if arg is None:
arg = []
...
----------
nosy: +georg.brandl
resolution: -> wont fix
status: open -> closed
__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue2561>
__________________________________
More information about the Python-bugs-list
mailing list