
Create the required inheriting metaclass on the fly:
def multi_meta(*clss): """A helper for inheriting from classes with different metaclasses.
Usage: 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 ethan@stoneleaf.us:
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
or:
class RQObject(metaclass=MetaQRegistrar): pass
class Spam(RQObject): pass
-- ~Ethan~
Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/