[Python-ideas] Syntax for allowing extra keys when unpacking a dict as keyword arguments
Juancarlo Añez
apalala at gmail.com
Sat Apr 13 08:59:35 EDT 2019
On Fri, Apr 12, 2019 at 11:10 AM Viktor Roytman <viktor.roytman at gmail.com>
wrote:
>
> The standard approach I have encountered in this scenario is to pass in
> the keyword arguments explicitly like so
>
> func(
> a=kwargs_dict["a"],
> b=kwargs_dict["b"],
> c=kwargs_dict["c"],
> )
>
func(**{k:v for k, v in d.items() if k in ('a','b','c'))
Or you can `def dict_filter(d, yes)` to the the above.
--
Juancarlo *Añez*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20190413/c28dadcb/attachment.html>
More information about the Python-ideas
mailing list