Skip to content

Instantly share code, notes, and snippets.

@Tjorriemorrie
Created September 8, 2016 05:20
Show Gist options
  • Save Tjorriemorrie/ed366ecee39d1724e4c6f54a4cbef1d3 to your computer and use it in GitHub Desktop.
Save Tjorriemorrie/ed366ecee39d1724e4c6f54a4cbef1d3 to your computer and use it in GitHub Desktop.
python inheritance with args
class A(object):
def __init__(self, astr='noA'):
print 'init A foo? {}'.format(astr)
class B_alpha(A):
def __init__(self, bstr='noB', *args, **kwargs):
print 'init B alpha bar? {}'.format(bstr)
super(B_alpha, self).__init__(*args, **kwargs)
class B_beta(A):
def __init__(self, *args, **kwargs):
print 'init B beta'
super(B_beta, self).__init__(*args, **kwargs)
class C(B_alpha, B_beta):
pass
c = C(astr='foo')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment