A decorator takes in a function, adds some functionality and returns it. This is also called metaprogramming as a part of the program tries to modify another part of the program at compile time.
def our_decorator(func):
def function_wrapper(x,y):
print "Unfortunately i called first "
print "Subtraction : {} + {} = {}".format(x,y,x-y)
# func(x,y)
return function_wrapper
@our_decorator
def addition(x,y):
print "Addition : {} + {} = {}".format(x,y,x+y)
addition(6,2)
#Output
# Unfortunately i called first
# Subtraction : 6 + 2 = 4