from functool import wraps
from lib import foo as old_foo
def decorator(func):
@wraps(func)
def wrapped(*args, **kwargs):
print('args: {}\n kwargs: {}'.format(args, kwargs)
result = func(*args, **kwargs)
print('result: {}'.format(result)
return result
#вариант 1
foo = decorator(old_foo)
#вариант 2
@decorator
def foo(*args, **kwargs):
return old_foo(*args, **kwargs)