[Python-ideas] PEP: Dict addition and subtraction

Del Gan delgan.py at gmail.com
Tue Mar 5 13:30:46 EST 2019


2019-03-05 0:34 UTC+01:00, Brandt Bucher <brandtbucher at gmail.com>:
>> Is there other built-in types which act differently if called with
>> the operator or augmented assignment version?
>
> list.__iadd__ and list.extend


2019-03-05 0:57 UTC+01:00, Guido van Rossum <guido at python.org>:
> Yes. The same happens for lists. [1] + 'a' is a TypeError, but a += 'a'
> works:


Oh, I can't believe I'm learning that just today while I'm using
Python since years.

Thanks for the clarification. This makes perfect sense for += to
behaves like .update() then.


More information about the Python-ideas mailing list