Python(僅限2?)查看變量__metaclass__的值,以確定如何根據類定義創建對象type。 It is possible to define __metaclass__ at the module or package level,在這種情況下,它適用於該模塊中的所有後續類定義。 不過,我遇到下面的flufl.enum包的__init__.py: __metaclass__ = typ
考慮以下情況的方法: class Meta(type):
def shadowed(cls):
print "Meta.shadowed()"
def unshadowed(cls):
print "Meta.unshadowed()"
class Foo(object):
__metaclass__ = Meta
def sh