Python decorators¶
functools.wraps
¶
import functools
def do_twice(func):
@functools.wraps(func)
def wrapper_do_twice(*args, **kwargs):
func(*args, **kwargs)
return func(*args, **kwargs)
return wrapper_do_twice
Class decorators¶
Need updated=()
Order of decorators¶
Expands outwards
decorator2(decorator1(my_fn()))
Last update:
2023-04-24