Skip to content

Instantly share code, notes, and snippets.

@mumumu
Created March 26, 2014 03:33
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 mumumu/9776546 to your computer and use it in GitHub Desktop.
Save mumumu/9776546 to your computer and use it in GitHub Desktop.
class First(object):
def __init__(self, a, b):
self.x = "first init %s" % a
self.y = "first init %s" % b
print "invoked!"
class Second(First):
pass
if __name__ == '__main__':
"""
$ python test.py
invoked!
hoge.x: first init 1
hoge.y: first init 2
invoked!
fuga.x: first init 3
fuga.y: first init 4
"""
hoge = First("1", "2")
print "hoge.x: %s" % hoge.x
print "hoge.y: %s" % hoge.y
fuga = Second("3", "4")
print "fuga.x: %s" % fuga.x
print "fuga.y: %s" % fuga.y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment