Re: [Python-ideas] Adding "+" and "+=" operators to dict

+1 on +=
Isn't that confusing ;-)
Yes, we have dict.update(), but the entire reason += exists (all the augmented assignment operators -- they are called that, yes?) is because we didn't want methods for everything.
It particular, I believe a major motivator was numpy, where in-place operations are a major performance boost. Sure, numpy could have added methods for all those, but the operator syntax is so much nicer, why not use it where we can?
And I prefer + to | ... Seems much more obvious to me.
Chris
-Chris

Chris Barker - NOAA Federal wrote:
Yes, we have dict.update(), but the entire reason += exists (all the augmented assignment operators -- they are called that, yes?) is because we didn't want methods for everything.
But it's mean to be an in-place version of whatever the + operator does on that type. It doesn't make sense for a type that doesn't have a + operator.
(And no, you can't argue that dict should be given a + operator just so you can give it a += operator!)

(And no, you can't argue that dict should be given a
- operator just so you can give it a += operator!)
Well, I like + anyway, so I don't need to even try that argument.
For the record, the fact that + doesn't work for sets is confusing to non-computer scientists, too. ( or logicians )
-Chris
-- Greg _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/
participants (2)
-
Chris Barker - NOAA Federal
-
Greg Ewing