New submission from Robert Hunger <[EMAIL PROTECTED]>: 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 http://docs.python.org/reference/compound_stmts.html#index-754) makes 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 messages: 77541 nosy: Pasha2009, christian.heimes, rhr severity: normal status: open title: Invalid Behaviour When a Default Argument is a Mutable Object type: behavior versions: Python 2.4, Python 2.5, Python 3.0 _______________________________________ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue4619> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com