I want to create a sub class "sub()" that can inherit either object "A(object)" or object "B(object)".
The following works for this:
class A(object):
def __init__(self):
print "Class A was inherited"
class B(object):
def __init__(self):
print "Class B was inherited"
class sub(A if inh==A else B):
def __init__(self,inh):
if inh==A:
A.__init__(self)
else:
B.__init__(self)
However, "inh" is not a defined parameter when I construct my "sub()". I want to be able to construct my "sub()" with an argument "inh" that initialize either "A(object)" or "B(object)".
So that:
my_object = sub(inh = A)
will give me:
Class A was inherited
And that:
my_object = sub(inh = B)
will give me
Class B was inherited
My problem is, how do I pass "inh" to the constructor "sub()" so it can choose the right object to inherit?