First page Back Continue Last page Overview Image

Decorator-Pattern

def decorator(function):

def wrapper(*args, **kwargs):

# do something before call to function

result = function(*args, **kwargs)

# do something after function call

return result

# update wrapper.__doc__ and .func_name

# or use functools.wraps

return wrapper