It doesn't contradict anything. Because you're calling SomeClass()
in the class definition (rather than __init__
), it's called when the class is defined, not when it is instantiated.
What happens when self.x += 1
is called, is that the value of self.x
is read from the class level, but then the assignment is made on the instance level, so a new x
is created that is specific to the instance.
You could try changing it from self.x
to MyHandler.x
and see what happens.