Skip to content

Instantly share code, notes, and snippets.

@sonsongithub
Created December 20, 2021 03:09
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 sonsongithub/31a22ddfb6a5e13951459ff4b00a98e7 to your computer and use it in GitHub Desktop.
Save sonsongithub/31a22ddfb6a5e13951459ff4b00a98e7 to your computer and use it in GitHub Desktop.
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