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

Mikhail V mikhailwas at gmail.com
Sun Nov 13 16:00:19 EST 2016


On 12 November 2016 at 21:08, João Matos <jcrmatos at gmail.com> wrote:

> What I would like to propose is the creation of the reverse:
> a =+ c is the same as a = c + a
> a =- c is the same as a = c - a
> a =* c is the same as a = c * a
> a =/ c is the same as a = c / a
> a =// c is the same as a = c // a
> a =% c is the same as a = c % a
> a =** c is the same as a = c ** a

A good syntax example:

a = sum (a, c)
a = mul (a, c)
a = div (a, c)

Another good syntax, I'm not a fan of, but at least intuitive and
learnt in school:

a = a + c
a = a * c
a = a / c

Bad syntax, not readable:

a += c
a -= c
a *= c

And your proposal: slightly different looking, but as bad
as above, at least I don't see any improvement of the look, actually
it makes even harder to see the beginning of the right part of assignment,
so IMO it is merely worsening of already bad syntax.
As for me, I would even prohibit all these +=  for the sake of readability.

Mikhail


More information about the Python-ideas mailing list