class classA:
def common(self):
print('A')
class classB:
def common(self):
print('B')
class classC:
def workflow(self):
print('Do something')
self.common()
print('Do something else')
A = classC() # Here I want to create classC that inherits from classA
A.workflow()
assert isinstance(A, classA)
B = classC() # Here I want to create classC that inherits from classB
B.workflow()
assert isinstance(B, classB)
In this example I have classA
and classB
that both implement a function common()
that outputs a different value. I'd like to have classC
inherit from one of those classes such that workflow()
will have a slightly different behavior depending on which common()
method it inherits. The main goal of this is to have one workflow()
method where the result of self.common()
changes depending on the inheritance.
How can I choose which class classC
inherits from when I instantiate classC
?