metaclass用来指定类是由谁创建的。
类的metaclass 默认是type。我们也可以指定类的metaclass值。在python3中
class MyType(type): def __call__(self, *args, **kwargs): return 'MyType' class Foo(object, metaclass=MyType): def __init__(self): return 'init' def __new__(cls, *args, **kwargs): return cls.__init__(cls) def __call__(self, *args, **kwargs): return 'call' obj = Foo()print(obj) # MyType



