Created
February 28, 2015 13:28
-
-
Save seungha-kim/0b579f1af22c5ed83d82 to your computer and use it in GitHub Desktop.
Method resolution order with diamond inheritance
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
""" | |
Method resolution order with diamond inheritance | |
>>> print(Class3.mro()) | |
[Class3, Class1_2, Class1_1, Class2, Class0, <class 'object'>] | |
""" | |
class Meta(type): | |
def __repr__(self): | |
return self.__name__ | |
class Class0(metaclass=Meta): | |
pass | |
class Class1_1(Class0): | |
pass | |
class Class1_2(Class1_1): | |
pass | |
class Class2(Class0): | |
pass | |
class Class3(Class1_2, Class2): | |
pass | |
if __name__=="__main__": | |
import doctest | |
doctest.testmod() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment