How to make function decorators and chain them together?
Asked 07 September, 2021
Viewed 824 times
  • 67
Votes

How can I make two decorators in Python that would do the following?

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

...which should return:

"<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.

17 Answer