class A(object):

    def do_something(self):
        print("I'm an A")


class AorB(object):

    def __init__(self):
        self.identity = A()

def changeToB(self):
    pass
Safe to change base class in python?