Four classes form a diamond: B and C both inherit from A, and D inherits from both.
class A:
def who(self):
return "A"
class B(A):
def who(self):
return "B" + super().who()
class C(A):
def who(self):
return "C" + super().who()
class D(B, C):
def who(self):
return "D" + super().who()
print(D().who(), [k.__name__ for k in D.__mro__])
What does the program print?
Log in to join the discussion.
Loading…