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

Eric Snow ericsnowcurrently at gmail.com
Fri Feb 13 00:43:43 CET 2015


On Thu, Feb 12, 2015 at 3:43 AM, Steven D'Aprano <steve at pearwood.info> wrote:
> A very strong -1 on the proposal. We already have a perfectly good way
> to spell dict += , namely dict.update. As for dict + on its own, we have
> a way to spell that too: exactly as you write above.

>From what I understand, the whole point of "d + d" (or "d | d") is as
an alternative to the PEP 448 proposal of allowing multiple keyword
arg unpacking clauses ("**") in function calls.  So instead of "f(**a,
**b)" it would be "f(**a+b)" (or "f(**a|b)").  However, the upside to
the PEP 448 syntax is that merging could be done without requiring an
additional intermediate dict.  Personally, I'd rather have the syntax
than the operator (particularly since it would apply to the dict
constructor as well: "dict(**a, **b, **c)").

-eric


More information about the Python-ideas mailing list