Created
February 20, 2014 01:45
-
-
Save teitei-tk/9105486 to your computer and use it in GitHub Desktop.
class methodの継承で一瞬迷ったのでおさらい。
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
#!/usr/bin/env python | |
class Hoge(object): | |
def run(self): | |
print "run as Hoge" | |
def second_run(self): | |
print "run as Hoge" | |
class Foo(Hoge): | |
def run(self): | |
print "run as Foo" | |
class Bar(Hoge): | |
pass | |
def run(): | |
hoge = Hoge() | |
foo = Foo() | |
bar = Bar() | |
hoge.run() # run as Hoge | |
hoge.second_run() # run as Hoge | |
foo.run() # run as Foo | |
bar.run() # run as Hoge | |
if __name__ == "__main__": | |
run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment