After almost two hours of debugging, I finally made an interesting (at least to me) discovery in Python: Attributes of type dictonary and list (and presumably all other object types) at the class level are "static" (as used in Java classes), while primitive types are not. Does that make sense? I don't know.

Consider the following dummy class:

class MyClass:
e = {"a":None}
f = [0]
i = 50
def __init__(self):
self.d = {"a":None}
def set(self, v):
self.d["a"] = v
self.e["a"] = v
self.f[0] = v


We have four attributes here:
e - a class level dictionary
f - a class level list
i - an int
d - another dictionary referenced by self.d inside the methods.

Now consider the following result from these interactive lines:

>>> x = MyClass()
>>> x.set(5)
>>> x.d
{'a': 5}
>>> x.e
{'a': 5}
>>> x.f
[5]
>>> y = MyClass()
>>> y.set(10)
>>> x.d
{'a': 5}
>>> x.e
{'a': 

10}
>>> x.f
[10]
>>>
>>> y.i = 100
>>> x.i
50
>>> y.i
100
>>>

As you can see, the first call to set method, set the value 5 in x.e, x.f and x.d. However, the second call, y.set(10), will also set the value of x.e and x.f (in red). Finally, it is shown that the int i does not conform to this behaviour.

Strange, I say.