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

Joshua Landau joshua at landau.ws
Sat Feb 14 00:34:18 CET 2015


On 13 February 2015 at 05:46, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> Eric Snow wrote:
>>
>> However, the upside to
>> the PEP 448 syntax is that merging could be done without requiring an
>> additional intermediate dict.
>
> It can also detect duplicate keywords and give you
> a clear error message. The operator would at best
> give a rather more generic error message and at
> worst silently discard one of the duplicates.

Since {1: 'a', 1: 'a'} is currently valid, it didn't make much sense
to detect duplicates. Unpacking into keywords as f(**d1, **d2) does
detect duplicates, however.


More information about the Python-ideas mailing list