I saw an article quite clearly : Python Function decorator
To sum up
# # Define decorator functions
def new_decorator(func):
@wraps(func)
def wrapThefunc(*args, **kwargs)
... # For functions func Do something
return func(*args, **kwargs)
return wrapThefunc
While in application
@new_decorator
def a_func()
...
It's essentially a_func = new_decorator(a_func) Of " Abbreviation " form , therefore , the @new_decorator After decoration , Reuse a_func(x) When you call wrapThefunc(x) This function .