Python is interpreted language and thus each type needs to be defined before it can be used in the program ahead. Try defining the
new_decorator
above your
func_needs_decorator
function.
def new_decorator(func):
def wrap_func():
print("Code would be here, before executing the func")
func()
print("Code here will execute after the func()")
return wrap_func
@new_decorator
def func_needs_decorator():
print("This function is in need of a Decorator")
func_needs_decorator()
Check out more here:
https://www.datacamp.com/community/tutorials/decorators-python[
^]