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

Viktor Roytman viktor.roytman at gmail.com
Fri Apr 12 12:01:43 EDT 2019


I could see this being an option, but to someone unfamiliar with it, it 
might seem strange that * unpacks iterables, ** unpacks dicts, and *** is a 
special thing only for keyword arguments that mostly behaves like **.

On Friday, April 12, 2019 at 11:26:37 AM UTC-4, Bruce Leban wrote:
>
>
> On Fri, Apr 12, 2019, 8:12 AM Viktor Roytman <viktor... at gmail.com 
> <javascript:> wrote:
>
>>
>>     >>> func(**{'a': 1, 'b': 2})
>>     Traceback (most recent call last):
>>       File "<stdin>", line 1, in <module>
>>     TypeError: func() got an unexpected keyword argument 'b'
>>
>
> Perhaps func(***kws)?
>
> I think this is a real problem given the frequent convention that you can 
> freely add fields to json objects with the additional fields to be ignored.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20190412/d3038520/attachment.html>


More information about the Python-ideas mailing list