Created
August 12, 2014 11:57
-
-
Save rrader/6baf0f4afd532c59fe11 to your computer and use it in GitHub Desktop.
Calling super in mixins
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 A(object): | |
| def m(self): | |
| print 'A1' | |
| try: | |
| super(A, self).m() | |
| except AttributeError: | |
| print 'A has no super.m()!' | |
| print 'A2' | |
| class B(object): | |
| def m(self): | |
| print 'B1' | |
| try: | |
| super(B, self).m() | |
| except AttributeError: | |
| print 'B has no super.m()!' | |
| print 'B2' | |
| class C(A, B): | |
| def m(self): | |
| print 'C1' | |
| super(C, self).m() | |
| print 'C2' | |
| c = C() | |
| c.m() | |
| print C.__mro__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment