Apologies this is a very broad question.
The code below is a fragment of something found on the web. The key thing I am interested in is the line beginning @protect
Decorator is just a function that takes another function as an argument
Simple Example:
def get_function_name_dec(func):
def wrapper(*arg):
function_returns = func(*arg) # What our function returns
return func.__name__ + ": " + function_returns
return wrapper
@get_function_name_dec
def hello_world():
return "Hi"
print(hello_world())