<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Mar 21, 2019 at 9:17 AM Serhiy Storchaka <<a href="mailto:storchaka@gmail.com">storchaka@gmail.com</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">21.03.19 14:51, Chris Angelico пише:<br>
> ... then, in the interests of productive discussion, could you please<br>
> explain? What is it about dict addition that makes it harder to<br>
> understand than other addition?<br>
<br>
Currently the + operator has 2 meanings for builtin types (both are <br>
widely used), after adding it for dicts it will have 3 meanings.<br>
<br>
3 > 2, is not?<br></blockquote><div><br></div>It depends how abstractly you define the "meanings".</div><div class="gmail_quote"><br></div><div class="gmail_quote">If you define + as "arithmetic addition" and "sequence concatenation", then yes, there are 2. But novices have to learn that the same concatenation operator applies to strings as well as lists/tuples. And when reading x + y, it is probably relevant whether x and y are numbers, strings, or sequence containers like lists.</div><div class="gmail_quote"><br></div><div class="gmail_quote">The proposal would generalize "sequence concatenation" to something like "asymmetric sequence/collection combination". (Asymmetric because d1 + d2 may not equal d2 + d1.) It seems a natural extension to me, though the | alternative is also reasonable (interpreted as taking the OR of keys in the two dicts; but unlike unioning two sets, the dict-merge operator would be asymmetric). The third proposed alternative, <<, has no "baggage" from an existing use as a combination operator, but at the same time it is a more obscure choice.<br clear="all"></div></div>