Is it possible to subclass dynamically? I know there's ____bases____ but I don't want to effect all instances of the class. I want the object cf to polymorph into a mixin of the DrvCrystalfontz class. Further into the hierarchy is a subclass of gobject that needs to be available at this level for connecting signals, and the solution below isn't sufficient.
class DrvCrystalfontz: def __init__(self, model, visitor, obj=None, config=None): if model not in Models.keys(): error("Unknown Crystalfontz model %s" % model) return self.model = Models[model] if self.model.protocol == 1: cf = Protocol1(self, visitor, obj, config) elif self.model.protocol == 2: cf = Protocol2(self, visitor, obj, config) elif self.model.protocol == 3: cf = Protocol3(self, visitor, obj, config) for key in cf.__dict__.keys(): self.__dict__[key] = cf.__dict__[key]