Skip to content

Instantly share code, notes, and snippets.

@kopos
Created January 6, 2021 17:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kopos/8ad5718f933434e24e124b629fbcec7b to your computer and use it in GitHub Desktop.
Save kopos/8ad5718f933434e24e124b629fbcec7b to your computer and use it in GitHub Desktop.
Python3 Inheritance MRO
class Parent(object):
def test(self):
print("parent")
class MyMixin(object):
def test(self):
super().test()
print("mixin")
class MyMixin2(object):
def test(self):
super().test()
print("mixin2")
class MyClass(MyMixin2, MyMixin, Parent):
def test(self):
super().test()
print("self")
if __name__ == "__main__":
my_obj = MyClass()
my_obj.test()
@kopos
Copy link
Author

kopos commented Jan 6, 2021

Output

$ python3 test2.py
parent
mixin
mixin2
self

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment