[Python-ideas] x )= f as shorthand for x=f(x)

Terry Reedy tjreedy at udel.edu
Fri Nov 9 21:11:16 CET 2007

"Boris Borcic" <bborcic at gmail.com> wrote in 
message news:fh1rhm$ui$1 at ger.gmane.org...
| Title says it all. Got used to += et al. My mind often expects augmented
| assignment syntax to exist uniformly for whatever transform.

I the analogy can be improved.

x += y # abbreviates
x = x + y # which could have been defined to have been written
x = +(x,y) # and which usually *is* equivalent to x = type(x).__add__(x,y)

Hence by analogy, I would rewrite
x = f(x,y) # as
x f= y # ;-)

Making the obvious generalization to n params, and specializing to one, 

x f=


More information about the Python-ideas mailing list