Last active
August 17, 2021 07:39
-
-
Save vene/3ba3a8fcd00c27fab4d004a4ac2931cb to your computer and use it in GitHub Desktop.
python multiple inheritance / mixin MRO
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 Base: | |
def say(self, val): | |
print("base says", val) | |
class A(Base): | |
def say(self, val): | |
print("say A") | |
super().say("A") | |
class B(Base): | |
def say(self, val): | |
print("say B") | |
super().say("B") | |
class Z(A, B): | |
def say(self): | |
super().say(None) | |
if __name__ == "__main__": | |
print(Z.mro()) | |
Z().say() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment