Decorator

import functools


def my_decorator(func):

@functools.wraps(func)

def wrapper_for_my_decorator(*args, **kwargs):

# do something before

func(*args, **kwargs)

# do something after

return func(*args, **kwargs)

return wrapper_for_my_decorator


@my_decorator

def myfunction():

...