= vs. == in Py3k

Bjorn Pettersen bjorn at roguewave.com
Fri Jun 9 15:54:44 EDT 2000


Lawrence Kesteloot wrote:
> 
> If one of the goals of Python 3000 is to make it easy for new
> programmers to learn, how about removing the distinction
> between = and ==?  The only kinds of examples I can think of
> where this is useful is something like:
> 
>     a = b = 5
> 
> vs.
> 
>     a = b == 5
> 
> But this isn't worth the trouble it gives new programmers.  The
> syntax could be changed to make = and == equivalent tokens
> and have the parser figure out which is meant from the context,
> just as it's done in Basic.  The documentation would only ever
> mention =, but the language would support == for backward
> compatibility.

[snip]

A much better suggestion would be to make := be the assignment token.
It's much clearer to distingush between :=/== vs =/==, and you wouldn't
have something that looks like equality meaning assignment (must be
better for the 4E crowd <wink>).

I'm no longer of the opinion that := should be an assignment expression
however.  I think we should investigate a ruby'esque solution instead:

  file.readline |line|:
    process(line)

or some similar syntax (where the |line|: <block> is a Smalltalk like
block / scheme like closure).  And yes, it would require both a
transparent closure mechanism and probably also gc.

-- bjorn

ps: you forgot the possibility that the user meant a==b==c <wink>




More information about the Python-list mailing list