from abc import ABCMeta
class test1(object):
__metaclass__ = ABCMeta
def test1(self):
print 'test1'
class UpperAttrMetaclass(type):
def __new__(cls, name, bases, dct={}):
a = super(UpperAttrMetaclass, cls).__new__(cls, name, bases, dct)
return a
b = UpperAttrMetaclass('hehe',(test1,),{})()
会报错如下:TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases
如果将test1中的__metaclass__ = ABCMeta
去掉就能运行。但是不想去掉,如何在以上基础上解决呢?(程序是在运行时动态决定继承哪些类,继承的类名和数量都不一定)