For class A, why is aMap member variable being shared between object and object b?
>>> class A:
... aMap = {}
>>> a = A()
>>> a.aMap["hello"] = 1
>>> b = A()
>>> b.aMap["world"] = 2
>>> c = []
>>> c.append(a)
>>> c.append(b)
>>> for i in c:
... for j in i.aMap.items():
... print j
('world', 2)
('hello', 1)
('world', 2)
('hello', 1)
Because you defined it as a class attribute, not instance attribute.
If you wish to have it as instance attribute and not be shared between instances, you have to define it like this: