Python Forum
Expanding on (+,*,%,/,//, etc...)= operator - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: General (https://python-forum.io/forum-1.html)
+--- Forum: News and Discussions (https://python-forum.io/forum-31.html)
+--- Thread: Expanding on (+,*,%,/,//, etc...)= operator (/thread-32709.html)



Expanding on (+,*,%,/,//, etc...)= operator - cuppajoeman - Feb-27-2021

I had an idea for how we write shorthand for a few binary functions (I'll use + as my example).

When we write
x += 2
, it really means
x = x + 2
, more generally since we can write addition as a binary relation, we can define it as
f
and then equivalently
x = f(x,2)
in that case, why not write the original statement as
x f= 2
?

On top of that for any function which isn't even binary, applying the same idea would yield the following shorthand for
x = g(x, a, b, c, ...)
to be
x g= a,b,c,...
What do you think?


RE: Expanding on (+,*,%,/,//, etc...)= operator - Gribouillis - Feb-27-2021

I think lines such as x = g(x, a, b, c) are not frequent enough to deserve such a special syntactic treatment. A language's syntax is a coherent set of carefully planned rules. Every odd idea must not be implemented.