Coming back from a bug hunt, i am not sure what to think of this python
behaviour. Here is a demo program:

class A:
   def __init__(self, lst=[]):
      self.lst = lst

a = A()
b = A()
b.lst.append("hallo")
print a.lst # output: ["hallo"]

The point seems to be, that lst=[] creates a class attribute (correct
name?), which is shared by all instances of A. So a.lst ist the same
object as b.lst, despite the fact, that object a is different to object
b.

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

Reply via email to