- 2024-04-25二三子钩
print ":
print "def inject_check(method),如上面代码中的hello函数加上@inject_check装饰器.hello()
就是在函数上加个包装:
# def hello(self);
return my_method
############################
#class Demo(object),等价于将函数hello重新赋值;hello":
# print ":
def my_method(*args);
method(*args)
print ":
@inject_check
def hello(self);before"after"
# hello=inject_check(hello)
##########################
class Demo(object);hello"
d = Demo()
d
赞186