# decorator function
def outer(func):
def inner():
str1 = func()
return str1.upper() # addition of functionality
return inner
@outer
def print_str():
return "good morning"
print(print_str())
# Output -> 'GOOD MORNING'
# A decorator is a function that takes another function as an argument, adds some kind of functionality to it and returns another function. Python decorators help add functionality to an existing code(function) which may aid in code reusability.
def log_result(func):
def inner():
res = func()
print(res)
return res