python class factory inherit random parent
问题 I have some code like this: class Person(object): def drive(self, f, t): raise NotImplementedError class John(Person): def drive(self, f, t): print "John drove from %s to %s" % (f,t) class Kyle(Person): def drive(self, f, t): print "Kyle drove from %s to %s" % (f,t) class RandomPerson(Person): # instansiate either John or Kyle, and inherit it. pass class Vehicle(object): pass class Driver(Person, Vehicle): def __init__(self): # instantiate and inherit a RandomPerson somehow pass d1 = Driver()