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

Andrew Barnert abarnert at yahoo.com
Fri Feb 13 08:28:07 CET 2015


On Feb 12, 2015, at 22:56, Steven D'Aprano <steve at pearwood.info> wrote:

> Some people here find + to be a plausible operator. I don't. I react to 
> using + for things which aren't addition in much the same way that I 
> expect you would react if I suggested we used ** as the operator. "Why 
> on earth would you want to use ** it's nothing like exponentiation!"

I'm not sure ** was the best example, because it also means both mapping unpacking and kwargs, both of which are _more_ relevant here than addition, not less. And ** for exponentiation is itself a little weird; you're just used to it at this point, if you don't find it weird anymore, that kind of argues against your point. Also, people have already suggested ridiculous things like << and ^ here, so you don't need to invent other ridiculous possibilities in the first place...

But anyway, I take your point, and I agree that either constructor and update with multiple args, or expanded unpacking, are better solutions than adding + if the problems can be worked out.


More information about the Python-ideas mailing list