Created
January 25, 2019 12:56
-
-
Save AdamSpannbauer/269dc8ded25238926979f7ab9867d719 to your computer and use it in GitHub Desktop.
demonstrating diamond problem stuff with super in python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class A: | |
def x(self): | |
print('x: A') | |
class B(A): | |
def x(self): | |
super().x() | |
print('x: B') | |
def y(self): | |
print('y: B') | |
def z(self): | |
print('z: B') | |
class C(A): | |
def x(self): | |
super().x() | |
print('x: C') | |
def y(self): | |
print('y: C') | |
def z(self): | |
print('z: C') | |
class D(C, B): | |
def z(self): | |
super().z() | |
print('z: D') | |
d = D() | |
d.x() | |
d.y() | |
d.z() | |
print(D.mro()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output: