For review: PEP 308 - If-then-else expression

Richard Jones rjones at
Sat Feb 8 00:33:25 CET 2003

On Sat, 8 Feb 2003 7:00 am, Dan Schmidt wrote:
> I am so keen on having a ternary operator in Python that I would
> probably vote yes on any proposal that was made.
> I dislike
>   if test:
>       x = a
>   else:
>       x = b
> not because it is longer than
>   x = a if test else b
> but because I think the intent of the code is much more clear if one
> says "x is the result of this computation depending on test" than if
> one says "if test is true, evaluate this body of code, otherwise
> evaluate this other body, and by the way they both happen to assign a
> value to x."

-1 for precisely the same reason

"x is the result of this computation ... oh, except if this is true, otherwise 
it's this"

No thanks.


More information about the Python-list mailing list