首页>itarticle>python decorator 2.Decorator with parameters 3.The best practice of decorator maybe 4.Class Decorator
python decorator 2.Decorator with parameters 3.The best practice of decorator maybe 4.Class Decorator
admin11月 12, 20200
The following two snippets are semantically identical
[code 1]
[code 2]
output
2.Decorator with parameters
The following two snippets are semantically identical
[code 3]
[code 4]
output
3.The best practice of decorator maybe
[code 5]
In code 4,if print func.__name__ in main, output will be __wrap,but in code 5,the output is func.
4.Class Decorator
The semantics and design goals of class decorators are the same as for function decorators; the only difference is that you’re decorating a class instead of a function.
近期评论