Last active
June 21, 2019 02:09
-
-
Save hahastudio/4c544040a8026e408600 to your computer and use it in GitHub Desktop.
gist for https://www.v2ex.com/t/157851 , a small sample for class
This file contains hidden or 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 Foo(object): | |
def talk(self, name): | |
raise NotImplementedError | |
def fly(self, ID): | |
raise NotImplementedError | |
class AAA(Foo): | |
def talk(self, name): | |
print "AAA: talking to %s now" % name | |
def fly(self, ID): | |
print "AAA: I think %s can fly" % ID | |
class BBB(Foo): | |
def talk(self, name): | |
print "BBB: talking to %s now" % name | |
def fly(self, ID): | |
print "BBB: I think %s can fly" % ID | |
def handle_check(CheckingClass): | |
ins = CheckingClass() | |
return ins | |
# test | |
h = handle_check(AAA) | |
h.talk("recall704") | |
# AAA: talking to recall704 now | |
h.fly(74234) | |
# AAA: I think 74234 can fly |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment