Created
January 6, 2021 17:50
-
-
Save kopos/8ad5718f933434e24e124b629fbcec7b to your computer and use it in GitHub Desktop.
Python3 Inheritance 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
Output |
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 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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output