<div dir="ltr">+1 for adding "+" or "|" operator for merging dicts. To me this operation:<div><br></div><div>>>> {'x': 1, 'y': 2} + {'z': 3}</div><div>{'x': 1, 'y': 2, 'z': 3}</div><div><br></div><div>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.:<br></div><div><br></div><div>>>> {'x': 1, 'y': 2} + {'x': 3}</div><div>{'x': 3, 'y': 2}<br></div><div><br></div><div>Which is analogous to the example:</div><div><br></div><div><div style="font-size:13px">new_dict = dict1.copy()</div><div style="font-size:13px">new_dict.update(dict2)</div></div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><br>~ Ian Lee<br></div></div>
<br><div class="gmail_quote">On Tue, Feb 10, 2015 at 12:11 AM, Serhiy Storchaka <span dir="ltr"><<a href="mailto:storchaka@gmail.com" target="_blank">storchaka@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 10.02.15 04:06, Ethan Furman wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
return func(*(args + fargs), **{**keywords, **fkeywords})<br>
</blockquote>
<br></span>
We don't use [*args, *fargs] for concatenating lists, but args + fargs. Why not use "+" or "|" operators for merging dicts?<div class="HOEnZb"><div class="h5"><br>
<br>
<br>
______________________________<u></u>_________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org" target="_blank">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" target="_blank">https://mail.python.org/<u></u>mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/ianlee1521%40gmail.com" target="_blank">https://mail.python.org/<u></u>mailman/options/python-dev/<u></u>ianlee1521%40gmail.com</a><br>
</div></div></blockquote></div><br></div>