They inherit from the same class, but cls passed to classmethod via super is the current class from which the method was called. super refers to the version of the base class of the method, but the cls for the call is the class in which the super call was made.
This is one of the subtle differences between:
def func(self): super(c, self).incr()
and
def func(self): a.incr()
You can confirm this by typing the current cls in your incr method in both cases:
def incr(cls): print cls ...
You must not allow all super execute a method call associated with the parent class. This is a lot more.
Keep in mind that when the first extended assignment += is executed, the initial value of var read from the base class (since at the moment it does not exist in dict subclasses). However, the updated value is written to a subclass. Calling super from the second subclass repeats the same behavior of reading the original var value from a .
source share