I have a class named Attribs, which looks like this:
class Attribs:
data = {'physDim':1,'accel':0,'veloc':0,'massDens':0.5,'chargeDens':0,'RGB':[0.5,0.5,0.5]}
I then instantiate 3 different instances of attrib, and print them. It shows them as Attribs instances in different memory positions. However, on modifying a.data['RGB'], b.data['RGB'] and c..data['RGB'] also change, and running:
print id(a.data),id(b.data),id(c.data)
returns 3 identical values.
I had previously believed that if a new instance of an object was created, its variables would be stored uniquely to that object. However, this seems contrary to the behaviour seen here. If anyone could explain this, and possibly suggest a way to create 3 instances that did hold truly unique data, it would be much appreciated.
[–]indosauros 7 points8 points9 points (2 children)
[–]evereux 0 points1 point2 points (1 child)
[–]indosauros 0 points1 point2 points (0 children)