I have a problem with my code. I want to apply the multiply inheritance in Python and I want to change the type of object instance at runtime with a method. For example:
class MyClassA:
def method(self):
#method A
class MyClassB:
def method(self):
#method B
class MyClassC(MyClassA, MyClassB):
def check():
...
if isinstance(my_instance, MyClassA):
#now you will use method of MyClassB
else:
# now you will use method of MyClassA
But this work only in the MyClass scope. How can I solve it?
UPDATE Thank you every one for the response. I try to be more clear. I have MyClassA and MyClassB with same methods. I want to use with the same object of MyClassC, in same cases method of MyClassA and in other cases method of MyClassB. So, at begin instance_classC.method() calls the method of MyClassA. After I have called instance_classC.check(), I want that, calling instance_classC.method(), this instruction calls the method of MyClassB.