[Python-ideas] Accepting multiple mappings as positional arguments to create dicts

Andrés Delfino adelfino at gmail.com
Thu Apr 12 15:32:41 EDT 2018


There's a long thread about the subject:
https://mail.python.org/pipermail/python-ideas/2015-February/031748.html

I suggest to avoid the matter altogether :)

On Thu, Apr 12, 2018 at 4:15 PM, Mike Miller <python-ideas at mgmiller.net>
wrote:

> While we're on the subject, I've tried to add dicts a few times over the
> years to get a new one but it doesn't work:
>
>     d3 = d1 + d2  # TypeError
>
> Thinking a bit, set union is probably a better analogue, but it doesn't
> work either:
>
>     d3 = d1 | d2  # TypeError
>
> Where the last value of any duplicate keys should win.
>
> -Mike
>
>
>
> On 2018-04-12 06:46, Andrés Delfino wrote:
>
>> Extending the original idea, IMHO it would make sense for the dict
>> constructor to create a new dictionary not only from several mappings, but
>> mixing mappings and iterables too.
>>
>> Consider this example:
>>
>> x = [(1, 'one')]
>> y = {2: 'two'}
>>
>> Now: {**dict(x), **y}
>> Proposed: dict(x, y)
>>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180412/7733604e/attachment.html>


More information about the Python-ideas mailing list