2019-01-24
python multiple inheritance from different paths with same method name
stackoverflow
Question

With the following code sample, can super be used, or C has to call A.foo and B.foo explicitly?

class A(object):
    def foo(self):
        print 'A.foo()'

class B(object):
    def foo(self):
        print 'B.foo()'

class C(A, B):
    def foo(self):
        print 'C.foo()'
        A.foo(self)
        B.foo(self)
Answer
1

super() will only ever resolve a single class type for a given method, so if you're inheriting from multiple classes and want to call the method in both of them, you'll need to do it explicitly. i.e.A.foo(self)

python multiple inheritance from different paths with same method name
See more ...