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

Paul Moore p.f.moore at gmail.com
Thu Feb 12 20:14:00 CET 2015


On 12 February 2015 at 18:43, Steven D'Aprano <steve at pearwood.info> wrote:
> I'm going to quote Raymond Hettinger, from a recent discussion here:
>
> [quote]
> I wouldn't read too much in the point score on the StackOverflow
> question.  First, the question is very old [...] Second, StackOverflow
> tends to award high scores to the simplest questions and answers [...] A
> high score indicates interest but not a need to change the language. A
> much better indicator would be the frequent appearance of ordered sets
> in real-world code or high download statistics from PyPI or
> ActiveState's ASPN cookbook.
> [end quote]

I'm surprised that this hasn't been mentioned yet in this thread, but
why not create a function, put it on PyPI and collect usage stats from
your users? If they are high enough, a case is made. If no-one
downloads it because writing your own is easier than adding a
dependency, that probably applies to adding it to the core as well
(the "new dependency" then would be not supporting Python <3.5 (or
whatever)). Converting a 3rd party function to a method on the dict
class isn't particularly hard, so I'm not inclined to buy the idea
that people won't use it *purely* because it's a function rather than
a method, which is the only thing a 3rd party package can't do.

I don't think it's a good use for an operator (neither + nor | seem
particularly obvious fits to me, the set union analogy
notwithstanding).

Paul


More information about the Python-ideas mailing list