two ideoms at one blow: line-reading and regexp-matching

Clark C . Evans cce at clarkevans.com
Sat Mar 23 09:58:18 EST 2002


On Thu, Feb 21, 2002 at 04:12:08PM +0000, Remco Gerlich wrote:
| Are you sure? writing 'if (a=3) {' must be the most common bug in C
| programs. I wouldn't call it successful. In fact, Python already caught
| three of those for me this week as syntax errors - that would have been bugs
| in C.

I'd note that good "C" style is to always put the constant
as the LVALUE in this way the above looks "funny".  In
other words when checking for equality in C, write "if (3==a) {"
this way if you forget the extra = you don't shoot yourself
in the foot (it is a syntax error).  A good lint program
should be able to flag these cases for you.  After a while
any equality test where the variable is on the left just
"looks funny"... 

Best,

Clark




More information about the Python-list mailing list