On Sun, Mar 25, 2018 at 4:40 PM, Tim Peters <tim.peters@gmail.com> wrote:
[Chris Angelico <rosuav@gmail.com>]
> ...
> Not qualitative, but anecdotal: I do sometimes have to remind my
> JavaScript students to check whether they've typed enough equals
> signs. And that's in a language where the normal comparison operator
> is ===. It's *still* not uncommon to see a comparison spelled =.

I wonder whether Guido remembers this ;-)  In the very, very, VERY
early days, Python didn't have "==".  Plain single "=" was used for
both assignment and equality testing.  So way back then. using "=" for
embedded assignment too was intractable on the face of it.

Wow, I did not remember this. In fact I had to track down the 0.9.1 release that's somewhere on the web to see for myself. :-) Should add this to the HOPL-IV paper if I end up writing it (I'm still far from decided either way).
I'm not clear on why it changed.  I remember writing to Guido about
how to disambiguate between the "bind" and "test for equality" intents
in isolated expressions typed at the interactive prompt, and next
thing I knew the language changed to use "==" for the latter.

Hm, that's probably why -- the desire for top-level expressions to allow comparison. Also probably the realization that this is one thing where (at the time) this particular difference with C/C++ was just annoying for most new users.

I'm assuming that <>, the ancient alternate spelling for != (that Barry still misses), came from the same source: ABC (https://homepages.cwi.nl/~steven/abc/qr.html#TESTS). But there was no compelling reason to remove <> (only to add !=) so it lingered until 3.0. Presumably ABC got both from Pascal (https://www.tutorialspoint.com/pascal/pascal_relational_operators.htm).
In any case, I really don't want to see plain "=" for embedded
assignments now.

I'm fond enough of ":=".  Icon used that for assignment (embedded or
otherwise), and I don't recall any bugs due to that.  It was hard to
confuse for "==" (whether conceptual confusion or visual confusion).

Most languages I learned in the '70s used it: both Algols, Pascal. (Though not Fortran.)
That was just prone to the _other_ problem with embedded assignments:
staring and staring trying to find the code where a name was most
recently bound - "oh!  it was bound inside the third nested clause in
the `while` test two pages back".  So it would be nice to combine
embedded assignment with some notion of limited scope - but I'm much
more concerned that the spelling not be easily confusable with "==".
But not really a fan of overly wordy spellings either.

The "two pages back" problem can happen just as easy with regular assignments or for-loop control variables.
There you go!  All the rest follows trivially from the Zen of Python ;-)

I gotta say I'm warming up to := in preference over 'as', *if* we're going to do this at all (not a foregone conclusion at all).

The scope question is far from easy though. I find it particularly grating that an inline assignment occurs in an 'if' statement, its scope is the entire body of the 'if'. If that body is two pages long, by the end of it the reader (or even the writer!) may well have lost track of where it was defined and may be confused by the consequence past the end of the body.

--Guido van Rossum (python.org/~guido)