Skip to content

Instantly share code, notes, and snippets.

@kjelly
Created March 16, 2014 14:25
Show Gist options
  • Save kjelly/9584023 to your computer and use it in GitHub Desktop.
Save kjelly/9584023 to your computer and use it in GitHub Desktop.
Python multi-inheritance , __init__ 。正常的 code
class A(object):
def __init__(self, parent=None):
super(A, self).__init__()
print 'init A class'
class B(object):
def __init__(self, parent=None):
super(B, self).__init__()
print 'init B class'
class C(A, B):
def __init__(self, parent=None):
super(self.__class__, self).__init__(parent)
print 'init C class'
c = C()
@kjelly
Copy link
Author

kjelly commented Mar 16, 2014

compre to this

-- coding: UTF8 --

class A(object):
def init(self, parent=None):
print 'init A class'

class B(object):
def init(self, parent=None):
print 'init B class'

class C(A, B):
def init(self, parent=None):
super(self.class, self).init(parent)
print 'init C class'

c = C()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment