I'm trying to understand Method Resolution Order in multiple inheirtance. Here's the code that I'm using.When I try to create the object of class 'ClassC', only the constructor of ClassA is getting called.How is the methods resolved in this case?
class ClassA:
def __init__(self):
print "inside a's init"
class ClassB:
def __init__(self):
print "inside b's init"
class ClassC(ClassA,ClassB):
pass
c = ClassC()
Output:
inside a's init
class ClassA(object):(in Python 3, all classes are new-style). And then addsuper(ClassA, self).__init__()to the.__init__method ofClassA. (You can also add a similar call toClassB, but it's not necessary becauseClassBis the end ofClassC's inheritance chain). If the answer by Python core dev Raymond Hettinger in the linked question doesn't fully answer your question, please let me know.