I was trying to create a physical model using Python when I came across some unintended behaviour of lists as the property of objects. When updating one of the elements inside the list of one object, the corresponding elements in other objects of the same class are also updated. I made the following minimal example for which this behaviour is replicated: class testClass: def __init__(self): pass a = [0, 0] b = 0 def __str__(self): return f"a = {self.a[0]}, b = {self.b}" def acc(self, i): self.b += i def inc(self, c): self.a[0] += self.b * c test = [testClass(), testClass()] test[0].acc(1) print(f"object 1: {test[0]}") # object 1: a = 0, b = 1 print(f"object 2: {test[1]}") # object 2: a = 0, b = 0 test[1].acc(2) print(f"object 1: {test[0]}") # object 1: a = 0, b = 1 print(f"object 2: {test[1]}") # object 2: a = 0, b = 2 test[0].inc(0.3) print(f"object 1: {test[0]}") # object 1: a = 0.3, b = 1 print(f"object 2: {test[1]}") # object 2: a = 0.3, b = 2 [This is unintended behaviour] test[1].inc(1) print(f"object 1: {test[0]}") # object 1: a = 2.3, b = 1 [This is unintended behaviour] print(f"object 2: {test[1]}") # object 2: a = 2.3, b = 2 Frustratingly, I have not found this issue documented anywhere online, yet it seems like such a fundamental problem with classes. Has anyone else encountered this? Am I doing something really dumb without realising? Any help would be appreciated. Continue reading...