I need to create a class that uses a different base class depending on some condition. With some classes I get the infamous:
TypeError: metaclass conflict: t
I like doing:
class mBase1(type):
...
class mBase2(type):
...
class Base1(metaclass=mBase1):
...
class Base2(metaclass=mBase2):
...
class mChild(type(Base1), type(Base2)):
pass
class Child(Base1, Base2, metaclass=mChild):
...
That way if something changes with the metaclass of the bases you don't have to worry about it. type()
will take care of it.