[Python-ideas] Reverse assignment operators (=+, =-, =*, =/, =//, =**, =%)

Jelle Zijlstra jelle.zijlstra at gmail.com
Mon Nov 14 22:55:43 EST 2016


2016-11-14 19:40 GMT-08:00 MRAB <python at mrabarnett.plus.com>:

> On 2016-11-15 02:59, Matthias welp wrote:
> [snip]
>
> e.g. if you use 'a = a + 1', python under the hood interprets it as
>> 'a = a.__add__(1)', but if you use 'a += 1' it uses 'a.__iadd__(1)'.
>>
>
> FTR, 'a += 1' is interpreted as 'a = a.__iadd__(1)'.

Or to be even more pedantic, `a = type(a).__iadd__(a, 1)`.

>
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20161114/20579b8f/attachment.html>


More information about the Python-ideas mailing list