A Bug By Any Other Name ...

MRAB python at mrabarnett.plus.com
Tue Jul 7 13:10:27 EDT 2009


Daniel Fetchinson wrote:
>>> and my point is that users
>>> are most of time correct when they assume that something will work the
>>> same way as in C.
>> Oh, really ? They would surely be wrong if they'd expect the for loop to
>> have any similarity with a C for loop, or - a *very* common error - if
>> they'd expect assignment to work the same way as in C.
> 
> By the way, assignments in conditionals. Guido explicitly referred to
> C when he forbade assignment in conditionals, citing common
> typos/errors in C code such as if( x = 5 ){ .... } instead of if( x ==
> 5 ){ ..... }. So even he realized that warning people about different
> usage in python and C is a good thing. Expectations from C work
> sometimes, and sometimes they don't. In latter case a little warning
> is useful.
> 
I wonder whether the problem with assignment in conditionals in C is due
to the assignment operator being "=". If it was ":=", would the error
still occur?



More information about the Python-list mailing list