Created
September 8, 2016 05:20
-
-
Save Tjorriemorrie/ed366ecee39d1724e4c6f54a4cbef1d3 to your computer and use it in GitHub Desktop.
python inheritance with args
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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