[Python-ideas] Syntax for allowing extra keys when unpacking a dict as keyword arguments

Chris Angelico rosuav at gmail.com
Sat Apr 13 09:02:39 EDT 2019


On Sat, Apr 13, 2019 at 11:00 PM Juancarlo Añez <apalala at gmail.com> wrote:
> func(**{k:v for k, v in d.items() if k in ('a','b','c'))
>

Would be really nice to be able to spell this as a dict/set intersection.

func(**(d & {'a', 'b', 'c'}))

ChrisA


More information about the Python-ideas mailing list