= vs. == in Py3k

Lawrence Kesteloot lk at veriomail.com
Fri Jun 9 02:18:26 EDT 2000


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.

(One problem I can see with this proposal is that "a = b = 5" would
probably mean "set A to whether B is equal to 5 or not", and this
is the less useful of the two interpretations.  I guess the parser
could be written to use the other.  Or the whole construct could be
disallowed since it's not terrifically useful anyway.)

(Um, the other problem is named arguments to functions.  I'm not
sure how to get around that.  Any suggestions?  That might be enough
to justify not doing this...)

Lawrence






More information about the Python-list mailing list