我需要创建一个根据某些条件使用不同基类的类。通过一些课程,我得到了臭名昭著的:
TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases
一个例子是 sqlite3
,下面是一个简短的例子,你甚至可以在解释器中使用:
>>> import sqlite3
>>> x = type('x', (sqlite3,), {})
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases