<div dir="ltr"><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Feb 27, 2019 at 10:42 AM Michael Selik <<a href="mailto:mike@selik.org">mike@selik.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Feb 27, 2019 at 10:22 AM Anders Hovmöller <<a href="mailto:boxed@killingar.net" target="_blank">boxed@killingar.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I dislike the asymmetry with sets:<br>
<br>
> {1} | {2}<br>
{1, 2}<br>
<br>
To me it makes sense that if + works for dict then it should for set too. <br>
<br>
/ Anders<br>
<br>
> On 27 Feb 2019, at 17:25, João Matos <<a href="mailto:jcrmatos@gmail.com" target="_blank">jcrmatos@gmail.com</a>> wrote:<br>
> <br>
> Hello,<br>
> <br>
> I would like to propose that instead of using this (applies to Py3.5 and upwards)<br>
> dict_a = {**dict_a, **dict_b}<br>
> <br>
> we could use<br>
> dict_a = dict_a + dict_b<br></blockquote><div><br></div><div><br></div>The dict subclass collections.Counter overrides the update method for adding values instead of overwriting values.</div><div class="gmail_quote"><br></div><div class="gmail_quote"><a href="https://docs.python.org/3/library/collections.html#collections.Counter.update" target="_blank">https://docs.python.org/3/library/collections.html#collections.Counter.update</a><br></div><div class="gmail_quote"><br></div><div class="gmail_quote">Counter also uses +/__add__ for a similar behavior.<br></div><div class="gmail_quote"><div><br></div><div><div>    >>> c = Counter(a=3, b=1)</div><div>    >>> d = Counter(a=1, b=2)</div><div>    >>> c + d # add two counters together:  c[x] + d[x]</div></div><div>    Counter({'a': 4, 'b': 3})</div><div><br></div><div>At first I worried that changing base dict would cause confusion for the subclass, but Counter seems to share the idea that update and + are synonyms.</div></div></div></div></blockquote><div><br></div><div>Great, this sounds like a good argument for + over |. The other argument is that | for sets *is* symmetrical, while + is used for other collections where it's not symmetrical. So it sounds like + is a winner here.<br></div><div> </div></div>-- <br><div dir="ltr" class="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido" target="_blank">python.org/~guido</a>)</div></div>