These are all class variables. Except when you assigned a.bar=4 create an instance variable. Basically, Python has an attribute search order. It goes:
instance -> class -> parent classes in MRO order (left to right)
So if you have
class Foo(object): bar = 1
This is a class variable Foo. As soon as you do
a = Foo() a.bar = 2
You have created a new variable on object a named bar . If you look at a.__class__.bar , you will still see 1, but it will be effectively hidden due to the order mentioned above.
The dict you created is at the class level, so it is shared between all instances of this class.
source share