Never needed this for lists but definitely had the pain for kwargs. Seems
very reasonable for that use case, +0.5.
In libraries I control I can make sure to use the same default values for
functions and their wrappers.
However when wrapping functions I don't control there is not a great way to
do this. And I end up
incrementally building up a kwargs dict. I suppose the same thing could
occur with *args lists so it makes sense for
both positional and keyword arguments.
Yes one could do something like:
```
def fun(a, b=0): ...
def wraps_fun(args, b=inspect.signature(fun).parameters['b'].default): ...
```
But I would hardly call that clear. Further it is not robust as would fail
if `fun` is itself wrapped in way
that destroys its signature. E.g.:
```
def destroy_signature(f):
# should decorate here with functools.wraps(f)
def wrapper(*args, **kwargs):
return f(*args, **kwargs)
return wrapper
```
Caleb
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/2EHOQDIIK7BMAY54KG44Z45IYWDDSZSW/
Code of Conduct: http://python.org/psf/codeofconduct/