首页 > 代码库 > Python type class metaclass

Python type class metaclass

‘type‘ 是 python built-in metaclass

其他继承自 ‘type’的class都可以是 Metaclass

子类可以继承父类的metaclass

然而 __metaclass__属性不能继承

__metaclass__可以定义成任何返回instance of ‘type‘ callable

 

 

__new__(cls, ...)  : create instance of cls

__init__(self, ...) :instance already created and set properties to this instance

 

Python type class metaclass