Skip to content

Instantly share code, notes, and snippets.

@raimon49
Created March 5, 2012 13:27
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 raimon49/1978299 to your computer and use it in GitHub Desktop.
Save raimon49/1978299 to your computer and use it in GitHub Desktop.
super()経由でSubの親であるBaseの__init__()を呼び出す
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# super 使う(Function.prototype.apply みたいな動き)
class Base(object):
def __init__(self):
print('Base')
class Sub(Base):
def __init__(self):
super(Sub, self).__init__()
print('Sub')
if __name__ == '__main__':
Sub()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment