Skip to content

Instantly share code, notes, and snippets.

@rdcoder33
Created December 26, 2018 12:04
Show Gist options
  • Save rdcoder33/f73b92884619b4937ffbdabb49683b7e to your computer and use it in GitHub Desktop.
Save rdcoder33/f73b92884619b4937ffbdabb49683b7e to your computer and use it in GitHub Desktop.
class Superclass:
super_class_call = 0
def class_call(self):
self.super_class_call += 1
print('I am Superclass')
class ClassA(Superclass):
class_a_call = 0
def class_call(self):
Superclass.class_call(self)
self.class_a_call += 1
print('I am ClassA')
class ClassB(Superclass):
class_b_call = 0
def class_call(self):
Superclass.class_call(self)
self.class_b_call += 1
print('I am ClassB')
class ClassC(ClassA, ClassB):
class_c_call = 0
def class_call(self):
ClassA.class_call(self)
ClassB.class_call(self)
self.class_c_call += 1
print('I am ClassC')
obj_c = ClassC()
obj_c.class_call()
print(
obj_c.super_class_call,
obj_c.class_a_call,
obj_c.class_b_call,
obj_c.class_c_call
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment