"?:", "a and b or c" or "iif"

Robert Meegan Robert.Meegan at wcom.com
Thu May 27 10:21:27 EDT 1999


On Thu, 27 May 1999, Magnus L. Hetland wrote:

[...]

> Instead of writing
> 
>   x = iif(a < b, y, z)
> 
> or
> 
>   z = a < b ? y : z
> 
> or
> 
>   z = a < b and y or z
> 
> you write
> 
>   if a < b:
>       z = y
>   else:
>       z = z
> 
> This is perfectly readable and standard.
> 

Hear! Hear!

I still don't understand what so many people have against writing simple
if/else statements. What ever happened to the idea that a line of code was
supposed to do one thing? When you write it like Magnus does, there are no
worrys about side effects or whether the second expression is evaluated.


--- Robert



--------------------------------
Robert Meegan
MCIWorldCom - Cedar Rapids, Iowa
319.375.2416





More information about the Python-list mailing list