if <assignment>:

Erik Max Francis max at alcyone.com
Tue Nov 26 19:22:05 EST 2002


Dave Brueck wrote:

> Ugh! Shame on any aspect of a language that burdens the developer this
> way. The fact that such strategies as the above have cropped up is,
> IMO,
> proof that the language is broken in that area. We don't say, "Is
> Tuesday
> today?" or "Is 5 your age?", either. :)

Yes, that convention to avoid mistaking = and == in an if (or other)
statement is extremely ugly and seems overkill.  I think the =/==
confusion in C and its descendent languages is being highly
overemphasized in this thread.  I came to Python from a C++, C and some
Java background, and I certainly don't miss assignment being a
full-fledged expression, and agree with avoiding the pitfalls.

The =/== mixup is indeed a very common beginner's error, particularly
when they come from a BASIC derivative language (where = means both
assignment and equality, depending on context).  In my experience,
however, among experienced programmers, repetition of this mistake is
extremely rare.  I literally cannot recall the last time that I made
this error, and have worked on sizeable teams and cannot recall finding
any colleagues' bugs stemming from the same mistake -- and this is not
from people who use the awful if (rvalue == lvalue) trick to prevent
them from getting it wrong in the first place.

I think the severity of the =/== confusion problem in C has been
severely overrepresented in this thread.  In my opinon, in the real
world, among competent software eengineers, it is a tiny issue.

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ Everyone wants to look good at his own funeral.
\__/ Louis Wu
    PyUID / http://www.alcyone.com/pyos/uid/
 A module for generating "unique" IDs in Python.



More information about the Python-list mailing list