I try to understand in more detail how the super class works, seemingly partially understood, but suddenly I fell for one of the examples that got me into a dead end. Here is the actual example:
class A(object): @classmethod def say_hello(cls): print 'A says hello' class B(A): @classmethod def say_hello(cls): super(B, cls).say_hello() print 'B says hello' class C(A): @classmethod def say_hello(cls): super(C, cls).say_hello() print 'C says hello' class D(B, C): @classmethod def say_hello(cls): super(D, cls).say_hello() print 'D says hello' D.say_hello()
result:
A says hello C says hello B says hello D says hello
I understand that the construction super (D, cls) .say_hello () leads us to the class B method, but something is confused why it then leads to class C, in class B we get super ((class 'B'), (D object )) and this leads us to C. Someone can explain this behavior to me?