Created
December 20, 2021 03:09
-
-
Save sonsongithub/31a22ddfb6a5e13951459ff4b00a98e7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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