[New-bugs-announce] [issue4619] Invalid Behaviour When a Default Argument is a Mutable Object
report at bugs.python.org
Wed Dec 10 14:55:37 CET 2008
New submission from Robert Hunger <rhunger at gmx.ch>:
Reopening of issue 4181.
Evaluating default parameter values when the function definition is
executed is a design bug.
Even the documentation of this behaviour (see
this clear by stating: "This is generally not what was intended." It
then makes a suggestion for a workaround ("A way around this ..."). Only
bugs need workarounds.
An interface or behaviour should fulfil a users expectation for the
"normal" case, not for some "special" case. For a default parameter
value a user expects that whenever this function gets called a new
instance of a mutable object is created. This is much closer to the
current behaviour for non-mutable objects.
Usage cases for the current default behaviour are less common.
components: Interpreter Core
nosy: Pasha2009, christian.heimes, rhr
title: Invalid Behaviour When a Default Argument is a Mutable Object
versions: Python 2.4, Python 2.5, Python 3.0
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce