Last active
August 29, 2015 14:04
-
-
Save mitchellrj/12acfd703bc75beb0236 to your computer and use it in GitHub Desktop.
Python multiple inheritance and super
This file contains hidden or 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 MetaMeta(object): | |
... def __init__(self): | |
... print ('metameta') | |
... | |
>>> class Meta(MetaMeta): | |
... def __init__(self): | |
... print ('meta1') | |
... | |
>>> class Meta2(MetaMeta): | |
... def __init__(self): | |
... print('meta2') | |
... | |
>>> class Class(Meta, Meta2): | |
... def __init__(self): | |
... super(Meta, self).__init__() | |
... super(Meta2, self).__init__() | |
... | |
>>> class Class2(Meta, Meta2): | |
... def __init__(self): | |
... super(Class2, self).__init__() | |
... super(Meta2, self).__init__() | |
... | |
>>> class Class4(Meta, Meta2): | |
... def __init__(self): | |
... super(Class3, self).__init__() | |
... super(Meta, self).__init__() | |
... | |
>>> obj = Class() | |
meta2 | |
metameta | |
>>> obj2 = Class2() | |
meta1 | |
metameta | |
>>> obj3 = Class3() | |
meta1 | |
meta2 | |
>>> obj4 = Class4() | |
meta1 | |
meta2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment