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, l, dct)
return a
b = UpperAttrMetaclass('hehe',(test1,),{})(3)
会报错如下: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去掉就能运行。但是如果不去掉如何
解决呢?(因为需要在程序运行时动态创建新类,继承类的种类和数量都是临时决定的)