Consider example:
def decorator(func):
def wrapper(*args, **kwargs):
print(args, kwargs)
func(*args, **kwargs)
return wrapper
@decorator
def foo(x, y, z=0):
pass
foo(5, 5)
Output:
(5, 5) {}
Why not (5, 5) {'z': 0}
? How to pass all default values of the function foo
to *args
or **kwargs
using only decorator (for functions) or metaclass (for class methods, e.g. __init__
)?