I've missed this feature on occasion as well. +1 for whatever that counts;

On Mon, 22 Mar 2021 at 17:30, Caleb Donovick <donov...@cs.stanford.edu>
wrote:

> 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 -- python-ideas@python.org
> To unsubscribe send an email to python-ideas-le...@python.org
> https://mail.python.org/mailman3/lists/python-ideas.python.org/
> Message archived at
> https://mail.python.org/archives/list/python-ideas@python.org/message/2EHOQDIIK7BMAY54KG44Z45IYWDDSZSW/
> Code of Conduct: http://python.org/psf/codeofconduct/
>
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/TWZVNIEE3R2ZLMSLPUCC27DJI5XH6MY3/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to