Say I have a class A
, B
and C
.
Class A
and B
are both mixin classes for Class C
.
Think of it this way -- you want the mixins to override some of the behaviors of object
, so they need to be before object
in the method resolution order.
So you need to change the order of the bases:
class C(A, B, object):
pass
Due to this bug, you need C
not to inherit from object directly to be able to correctly assign to __bases__
, and the factory really could just be a function:
class FakeBase(object):
pass
class C(FakeBase):
pass
def c_factory():
for base in (A, B):
if base not in C.__bases__:
C.__bases__ = (base,) + C.__bases__
return C()