Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
class A:
def __init__(self, name):
self.name = name
def doit(self):
print(self.name + " doit by class A")
def dodo(self):
self.doit()
class B(A):
def doit(self):
print(self.name + " doit by class B")
instance_a = A("a")
instance_b = B("b")
instance_a.dodo()
instance_b.dodo()
# > python derivation.py
# a doit by class A
# b doit by class B
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment