Have a look a this simple example. I don't quite understand why o1 prints "Hello Alex" twice. I would think that because of the default self.a is always reset to the empty list. Could someone explain to me what's the rationale here? Thank you so much.
class A(object): def __init__(self, a=): self.a = a o = A() o.a.append('Hello') o.a.append('Alex') print ' '.join(o.a) # >> prints Hello Alex o1 = A() o1.a.append('Hello') o1.a.append('Alex') print ' '.join(o1.a) # >> prints Hello Alex Hello Alex
© Stack Overflow or respective owner