Create the required inheriting metaclass on the fly:

def multi_meta(*clss):
    """A helper for inheriting from classes with different metaclasses.

        class C(multi_meta(A, B)):
            "A class inheriting from classes A, B with different metaclasses."
    mcss = tuple(type(cls) for cls in clss)
    mcs = type(
        "Meta[{}]".format(", ".join(mcs.__name__ for mcs in mcss)), mcss, {})
    return mcs("[{}]".format(", ".join(cls.__name__ for cls in clss)), clss, {})

I have the same use-case as you, i.e. mixing custom metaclasses with QObjects.

2015-02-12 10:36 GMT-08:00 Ethan Furman <>:
On 02/12/2015 05:42 AM, Martin Teichmann wrote:

> class MetaQRegistrar(MetaRegistrar, type(QObject)):
>     pass
> but then you always have to write something like
> class Spam(Registrar, QObject, metaclass=MetaQRegistrar):
>     pass


  class RQObject(metaclass=MetaQRegistrar):

  class Spam(RQObject):


Python-ideas mailing list
Code of Conduct: