programming-examples/python/Function/Python program to make a chain of function decorators (bold, italic, underline etc.py

20 lines
487 B
Python
Raw Normal View History

2019-11-15 12:59:38 +01:00
def make_bold(fn):
def wrapped():
return "<b>" + fn() + "</b>"
return wrapped
def make_italic(fn):
def wrapped():
return "<i>" + fn() + "</i>"
return wrapped
def make_underline(fn):
def wrapped():
return "<u>" + fn() + "</u>"
return wrapped
@make_bold
@make_italic
@make_underline
def hello():
return "hello world"
print(hello()) ## returns "<b><i><u>hello world</u></i></b>"