= vs. == in Py3k

Radovan Garabik garabik-news at spam.melkor.dnp.fmph.uniba.sk
Fri Jun 9 08:11:55 EDT 2000


Lawrence Kesteloot <lk at veriomail.com> 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.

 : (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.)

AFAIK, pre-1.0 python did not have == operator.
The problem is, how to interpret a=b in interactive python?
Should it return 1 or 0, depending on whether a equals b, or should it
assign b to a?


-- 
 -----------------------------------------------------------
| Radovan Garabik http://melkor.dnp.fmph.uniba.sk/~garabik/ |
| __..--^^^--..__    garabik @ melkor.dnp.fmph.uniba.sk     |
 -----------------------------------------------------------
Antivirus alert: file .signature infected by signature virus.
Hi! I'm a signature virus! Copy me into your signature file to help me spread!



More information about the Python-list mailing list