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)
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)