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

2019-04-13 Thread Juancarlo Añez
On Fri, Apr 12, 2019 at 11:10 AM Viktor Roytman 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(**

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

2019-04-13 Thread Chris Angelico
On Sat, Apr 13, 2019 at 11:00 PM Juancarlo Añez 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 ___ Python-ideas mailing

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

2019-04-13 Thread Viktor Roytman
On Saturday, April 13, 2019 at 9:03:54 AM UTC-4, Chris Angelico wrote: > > On Sat, Apr 13, 2019 at 11:00 PM Juancarlo Añez > 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', '

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

2019-04-13 Thread Juancarlo Añez
On Sat, Apr 13, 2019 at 9:02 AM Chris Angelico wrote: > Would be really nice to be able to spell this as a dict/set intersection. > > func(**(d & {'a', 'b', 'c'})) > That would be _very_ consistent with the ongoing discussions about operators over dicts. -- Juancarlo *Añez* ___

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

2019-04-13 Thread Chris Angelico
On Sun, Apr 14, 2019 at 10:15 AM Juancarlo Añez wrote: > > > > On Sat, Apr 13, 2019 at 9:02 AM Chris Angelico wrote: >> >> Would be really nice to be able to spell this as a dict/set intersection. >> >> func(**(d & {'a', 'b', 'c'})) > > > That would be _very_ consistent with the ongoing discussio