Decorator
- During the code is running, the way to dynamically increase the function
decorator
The essence of is a higher order functiondecorator
Accepts a function as a parameter and returns a function
Examples of decorators:
import functools
def log(text):
def decorator(func):
@functools.warps(func)
def wap(*args, **kw):
print (text)
func(*args, **kw)
return wap
return decorator
@log("this is a test")
def now()
print (datetime.datetime.now())
Which @functools.warps(func)
is to __name__
process the properties of the function