[Python-ideas] adding dictionaries

Paul Moore p.f.moore at gmail.com
Mon Jul 28 21:21:54 CEST 2014


On 28 July 2014 19:58, Nathan Schneider <nathan at cmu.edu> wrote:
> Here are two threads that had some discussion of this:
> https://mail.python.org/pipermail/python-ideas/2011-December/013227.html

This doesn't seem to have a use case, other than "it would be nice".

> https://mail.python.org/pipermail/python-ideas/2013-June/021140.html.

This can be handled using ChainMap, if I understand the proposal.

> Seems like a useful feature if there could be a clean way to spell it.

I've yet to see any real-world situation when I've wanted "dictionary
addition" (with any of the various semantics proposed here) and I've
never encountered a situation where using d1.update(d2) was
sufficiently awkward that having an operator seemed reasonable.

In all honesty, I'd suggest that code which looks bad enough to
warrant even considering this feature is probably badly in need of
refactoring, at which point the problem will likely go away.

Paul


More information about the Python-ideas mailing list