[Python-ideas] Adding "+" and "+=" operators to dict
Paul Moore
p.f.moore at gmail.com
Thu Feb 12 21:19:02 CET 2015
On 12 February 2015 at 19:27, Donald Stufft <donald at stufft.io> wrote:
> Honestly I don’t think "put it on PyPI" is a very useful thing in cases like
> these. Consuming a dependency from PyPI has a cost, such the same as dropping
> support for some version of Python has a cost. For something with an easy
> enough work around the cost is unlikely to be low enough for people to be
> willing to pay it.
>
> Python often gets little improvements that on their own are not major
> enhancements but when looked at cumulatively they add up to a nicer to use
> language. An example would be set literals, set(["a", "b"]) wasn't confusing
> nor was it particularly hard to use, however being able to type {"a", "b"} is
> nice, slightly easier, and just makes the language jsut a little bit better.
>
> Similarly doing:
>
> new_dict = dict1.copy()
> new_dict.update(dict2)
>
> Isn't confusing or particularly hard to use, however being able to type that
> as new_dict = dict1 + dict2 is more succinct, cleaner, and just a little bit
> nicer. It adds another small reason why, taken with the other small reasons,
> someone might want to drop an older version of Python for a newer version.
Well put. My previous post was uncalled for.
I'm still not sure I agree that the proposal is worth it, but this is
a good argument in favour (and confirms my feeling that *if* it were
to happen, spelling it as addition is the right way to do so).
Paul
More information about the Python-ideas
mailing list