Skip to content

Instantly share code, notes, and snippets.

@vene
Last active August 17, 2021 07:39
Show Gist options
  • Save vene/3ba3a8fcd00c27fab4d004a4ac2931cb to your computer and use it in GitHub Desktop.
Save vene/3ba3a8fcd00c27fab4d004a4ac2931cb to your computer and use it in GitHub Desktop.
python multiple inheritance / mixin MRO
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