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

Richard Jones rjones at ekit-inc.com
Fri Feb 7 18:33:25 EST 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.


   Richard






More information about the Python-list mailing list