Hello,

I would like to propose some reversed assignment operators.

Python already has some assignment operators:
a += c is the same as a = a + c
a -= c is the same as a = a - c
a *= c is the same as a = a * c
a /= c is the same as a = a / c
a //= c is the same as a = a // c
a %= c is the same as a = a % c
a **= c is the same as a = a ** c

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

For addition (+= and =+), multiplication (*= and =*) and subtraction (-= and =-) of numbers it would give the same result, but addition (+= and =+) and multiplication (*= and =*) when used with strings return a different result.
All the other operations (=/, =%, =** and =//) return a different result.

I think it is simple and easy to understand, therefore pythonic. :)

Best regards,

JM

_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to