I come from Java and I'm learning Python.
I want to work with a list of objects which contains a list of elements.
class O:
o = []
def add(self, i):
self.o.append(i)
def long(self):
return len(self.o)
list = [ O(), O() ]
Why calling 'add' at the first object is done also in the second?
>>> list[0].long()
0
>>> list[1].long()
0
>>> list[0].add(3)
>>> list[0].long()
1
>>> list[1].long()
1
What I'm doing wrong?