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

Stephen J. Turnbull stephen at xemacs.org
Sat Nov 10 00:26:21 CET 2007

Boris Borcic writes:

 > I must admit I wasn't expecting the discussion to rely so quickly
 > on involving my character.

Some people have natural talent for a particular kind of design, some
don't.  If one doesn't, it's no big deal, s/he still can contribute,
even to design---but coming up with original ideas is likely to waste
her/his time and that of others.  (I don't say it's impossible to
develop it as a skill, but it would take real work.)

Why not take Guido's comment literally, "*if* you don't have it," and
think about the "litmus test" he described?  (Ie, think about why this
proposal is unattractive.)  Of course, there is an implication that
you *don't* have it, but it will be better all around if you ignore
that implication, and leave it an open question as long as you want to
contribute in this way.

 > In conclusion, I guess I'm warranted to take this to mean "we can
 > dream up no appropriate syntax".

I wouldn't say "impossible".  However, the senior developers who have
spoken up clearly think that your proposal (a) is not an improvement
over x = f(x) in most use cases (and IMO often would be worse, because
x += y expresses accumulation of y, while x = y expresses replacement)
and (b) seems to have very few, if any, appropriate use cases.  So
"why bother?" is the message.

 > PS,FYI : a notation borne from letting parens live independent lives,
 > and indeed could fly http://en.wikipedia.org/wiki/Bra-ket_notation

As I understand it, the bra-ket notation arose in physics because both
the bra part and the ket part make sense as operators, but only in the
lefthand role for the bra, and righthand role for the ket.  So they
don't really live independent lives, any more than the dx and the dy
do in conventional calculus.

However, in your syntax you do (c) lose the kind of implied symmetry
that the bra-ket and infinitesimal notations have.  You could "fix"
that by using the notation "apply-and-assign" x ()= f, but that
syntax already has a meaning in python, and runs even more forcefully
into STeVe's criticism that parens are a postfix operator, not infix.

Note that I myself can come up with criticisms like (a), (b), and (c)
but to the best of my knowledge I've never invented any useful

I-always-wanted-to-be-a-language-designer-too-ly y'rs,

More information about the Python-ideas mailing list