Skip to content

Instantly share code, notes, and snippets.

@markpasc
Created May 13, 2011 19:29
Show Gist options
  • Save markpasc/971155 to your computer and use it in GitHub Desktop.
Save markpasc/971155 to your computer and use it in GitHub Desktop.
python diamond inheritance works
class Base(object):
def data(self):
return {'base': True}
class A(Base):
def data(self):
data = super(A, self).data()
data.update({'a': True})
return data
class B(Base):
def data(self):
data = super(B, self).data()
data.update({'b': True})
return data
class C(A, B):
def data(self):
data = super(C, self).data()
data.update({'c': True})
return data
print repr(C().data())
$ python diamond.py
{'a': True, 'c': True, 'base': True, 'b': True}
$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment