+1 for adding "+" or "|" operator for merging dicts. To me this operation:
>>> {'x': 1, 'y': 2} + {'z': 3}
{'x': 1, 'y': 2, 'z': 3}
Is very clear. The only potentially non obvious case I can see then is
when there are duplicate keys, in which case the syntax could just be
defined that last setter wins, e.g.:
>>> {'x': 1, 'y': 2} + {'x': 3}
{'x': 3, 'y': 2}
Which is analogous to the example:
new_dict = dict1.copy()
new_dict.update(dict2)
~ Ian Lee
On Tue, Feb 10, 2015 at 12:11 AM, Serhiy Storchaka <[email protected]>
wrote:
> On 10.02.15 04:06, Ethan Furman wrote:
>
>> return func(*(args + fargs), **{**keywords, **fkeywords})
>>
>
> We don't use [*args, *fargs] for concatenating lists, but args + fargs.
> Why not use "+" or "|" operators for merging dicts?
>
>
>
> _______________________________________________
> Python-Dev mailing list
> [email protected]
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: https://mail.python.org/mailman/options/python-dev/
> ianlee1521%40gmail.com
>
_______________________________________________
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com