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

Chris Barker - NOAA Federal chris.barker at noaa.gov
Fri Feb 13 04:43:36 CET 2015


> avoids any confusion over operators and having += duplicating the
> update method.

+= duplicates the extend method on lists.

And it's really redundant for numbers, too:

x += y

x = x + y

So plenty of precedent.

And my experience with newbies (been teaching intro to python for a
few years) is that they grab onto + for concatenating strings really
quickly. And I have a hard time getting them to use other methods for
building up strings.

Dicts in general come later, but are key to python. But I don't know
that newbies expect + to work for dicts or not -- updating a dict is
simply a lot less common.

-Chris


More information about the Python-ideas mailing list