C Barr Leigh a écrit :
> Help! Have I found a serious bug?

No. This is a FAQ. Default arguments of functions are evaled only once - 
when the def statement is eval'd and the function object constructed.

> This seems like highly undesired behaviour to me.

Possibly, but this is unlikely to change in a near future, so you'd 
better get used to it. If you want mutable objects as default values for 
functions, the idiom is:

def some_func(default=None):
   if default is None:
     default = []
   # code here

HTH
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to