Skip to content

Instantly share code, notes, and snippets.

@rdcoder33
Last active December 26, 2018 12:25
Show Gist options
  • Save rdcoder33/5fbc3999e8225ac2d765decc9f705561 to your computer and use it in GitHub Desktop.
Save rdcoder33/5fbc3999e8225ac2d765decc9f705561 to your computer and use it in GitHub Desktop.
class Superclass:
super_class_call = 0
def class_call(self):
print('I am Superclass')
self.super_class_call += 1
class ClassA(Superclass):
class_a_call = 0
def class_call(self):
#new
super().class_call()
self.class_a_call += 1
print('I am ClassA')
class ClassB(Superclass):
class_b_call = 0
def class_call(self):
# new
super().class_call()
self.class_b_call += 1
print('I am ClassB')
class ClassC(ClassA, ClassB):
class_c_call = 0
def class_call(self):
#new
super().class_call()
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