Sep-03-2017, 11:10 PM
I am a newbie trying to learn programming. Here is my decorator toy code. It throws syntax error when I call the argument function.
def boldtext(fn):"""This is the 1st decorator function"""
result = "<b>" + fn + "</b>"
return result
def italicizetext(fn): """This is the 2nd decorator function"""
result = "<i>" + fn() + "</i>"
return result
@boldtext
@italicizetext
def printsampletext(): """This is the argument function"""
return "Some sample text!"
printsampletext()
def boldtext(fn):"""This is the 1st decorator function"""
result = "<b>" + fn + "</b>"
return result
def italicizetext(fn): """This is the 2nd decorator function"""
result = "<i>" + fn() + "</i>"
return result
@boldtext
@italicizetext
def printsampletext(): """This is the argument function"""
return "Some sample text!"
printsampletext()