如何制做功能装饰器链? - How to make a chain of function decorators?

问题:

How can I make two decorators in Python that would do the following? 如何在Python中制做两个装饰器,以完成如下工做? app

@makebold
@makeitalic
def say():
   return "Hello"

...which should return: ...应返回: this

"<b><i>Hello</i></b>"

I'm not trying to make HTML this way in a real application - just trying to understand how decorators and decorator chaining works. 我并非想在真实的应用程序中以这种方式制做HTML ,而是试图了解装饰器和装饰器连接的工做方式。 spa


解决方案:

参考一: https://stackoom.com/question/36Pu/如何制做功能装饰器链
参考二: https://oldbug.net/q/36Pu/How-to-make-a-chain-of-function-decorators
相关文章
相关标签/搜索