metaclass 和 方法装饰器哪一个先执行
def deco(function):
print ‘i am in deco‘
return function
class MetaClass(type):
def __init__(cls,name,bases,attr):
print ‘i am in MetaClass‘
class Home(object):
__metaclass__ = MetaClass
@deco
def index(self):
print ‘i am in index‘
Home()
# i am in deco
# i am in MetaClass
时间: 2024-10-11 10:45:09