[Python-ideas] Dict joining using + and +=

francismb francismb at email.de
Sat Mar 2 15:25:05 EST 2019


On 3/2/19 8:14 PM, Raymond Hettinger wrote:
> Lastly, I'm still bugged by use of the + operator for replace-logic instead of additive-logic.  With numbers and lists and Counters, the plus operator creates a new object where all the contents of each operand contribute to the result.  With dicts, some of the contents for the left operand get thrown-away.  This doesn't seem like addition to me (IIRC that is also why sets have "|" instead of "+").
+1, it's a good point. IMHO the proposed (meaning) overloading for + and
+= is too much/unclear. If the idea is to 'join' dicts why not to use
"d.join(...here the other dicts ...)"

Regards,
--francis


More information about the Python-ideas mailing list