Skip to content

Instantly share code, notes, and snippets.

@hahastudio
Last active June 21, 2019 02:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save hahastudio/4c544040a8026e408600 to your computer and use it in GitHub Desktop.
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
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