Python newbie here, would appreciate some help with multiple inheritance!
Consider the following class hierarchy:
class Base1:
def display(self):
print('Base1')
class Base2:
def display(self):
print('Base2')
class Derived1 (Base1):
def display(self):
super().display()
print('Derived1')
class Derived2 (Base2):
def display(self):
super().display()
print('Derived2')
class Derived (Derived1, Derived2):
def display(self):
super().display()
print('Derived')
Derived().display()
I was expecting that the output of this would print the names of all the classes involved in the hierarchy, but it's not so. Further, if I add super().display()
to both Base1
and Base2
, I get the error AttributeError: 'super' object has no attribute 'display'
.
What's wrong?