PEP308 - preference for 'x if c else y' over 'c then x else y'

Erik Max Francis max at alcyone.com
Sun Feb 16 11:06:20 EST 2003


"Colin J. Williams" wrote:

> PS  The simplest scheme, suggested by others, which keeps
> the condition on the left is probably:
> 
>     if (cond, choiceT, choiceF)
> 
> where "if" is a function defined as: ...

This doesn't implement short circuiting, which is the whole purpose of a
conditional operator.  See the PEP; this scheme is explcitly rejected.

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ You win the victory when you yield to friends.
\__/ Sophocles
    Crank Dot Net / http://www.crank.net/
 Cranks, crackpots, kooks, & loons on the Net.




More information about the Python-list mailing list