When debugging, I like to print out all the inputs and outputs of a function (I know I need a better IDE, but humour me, this could be used for error reporting). So, I\'d id
You can use as decorator for debug; (@debug)
def debug(func):
import functools
@functools.wraps(func)
def wrapper_debug(*args, **kwargs):
args_repr = [repr(a) for a in args] # 1
kwargs_repr = [f"{k}={v!r}" for k, v in kwargs.items()] # 2
signature = ", ".join(args_repr + kwargs_repr) # 3
print(f"Call {func.__name__}({signature})")
value = func(*args, **kwargs)
print(f"{func.__name__!r} return {value!r}") # 4
return value
return wrapper_debug