Skip to content

Instantly share code, notes, and snippets.

@esoergel
Last active August 29, 2015 14:15
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 esoergel/ba14cbd9a5c469a33dd1 to your computer and use it in GitHub Desktop.
Save esoergel/ba14cbd9a5c469a33dd1 to your computer and use it in GitHub Desktop.
Python multiple inheritance
class A1(object):
def __init__(self):
print "Class A1"
super(A1, self).__init__()
class A2(A1):
def __init__(self):
print "Class A2"
super(A2, self).__init__()
class B1(object):
def __init__(self):
print "Class B1"
super(B1, self).__init__()
class B2(B1):
def __init__(self):
print "Class B2"
super(B2, self).__init__()
class C(B2, A2):
def __init__(self):
print "Class C"
super(C, self).__init__()
C()
# Output:
Class C
Class B2
Class B1
Class A2
Class A1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment