这是一段 flask_admin 的代码
继承自type和继承自object有什么不同?
为什么要用type.__init__() 调用type的 __init__, type里有东西吗?
class AdminViewMeta(type):
"""
View metaclass.
Does some precalculations (like getting list of view methods from the class) to avoid
calculating them for each view class instance.
"""
def __init__(cls, classname, bases, fields):
type.__init__(cls, classname, bases, fields)
1
aisk 2015-06-09 10:52:20 +08:00
这是个 metaclass,请参考: http://stackoverflow.com/questions/100003/what-is-a-metaclass-in-python
|