Unexpected default arguments behaviour (Maybe bug?)
Sebastian "lunar" Wiesner
basti.wiesner at gmx.net
Fri Jul 18 13:23:03 CEST 2008
sukkopera at gmail.com <sukkopera at gmail.com>:
> On 13 Lug, 19:42, marek.ro... at wp.pl wrote:
>> I expect it's because default values for parameters are evaluated and
>> bound at definition time. So once "def m (self, param = a):" line
>> executes, the default value for parameter is forever bound to be 1.
>> What you can do is for example:
> Yes, that's what I thought, too. Although, it does not seem to me the
> correct thing that has to be done, that is why I reported it.
It _is_ the correct thing. Evaluation of default parameters at "declaration
time" and not at invocation is truely a language feature, not a bug.
You'll find your bug report being closed quickly.
Freedom is always the freedom of dissenters.
More information about the Python-list