beza1e1> class A:
beza1e1> def __init__(self, lst=[]):
beza1e1> self.lst = lst
Lists are mutable and default args are only evaluated once, at function
definition. If you want independent default args use:
class A:
def __init__(self, lst=None):
if lst is None:
lst = []
self.lst = lst
The same scheme would work for other mutable types (dicts, sets, etc).
This same question gets asked once a month or so. I'm sure this is in the
Python FAQ (check the website), but it was faster to reply than to look it
up...
Skip
--
http://mail.python.org/mailman/listinfo/python-list