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

Paul Rubin http
Mon Feb 10 16:22:24 EST 2003


Tim Peters <tim.one at comcast.net> writes:
> outside of Usenet posts.  Offhand, at first glance I don't find
> 
>     y if x else b
> 
> any more sensible than
> 
>     x and y or b
> 
> At least the meaning of the latter follows directly from what
> Python's "and" and "or" mean in isolation.

"follows directly" here seems to mean "is implicit in", which takes us
back to explicit being better than implicit.

And as keeps getting posted, the second version gives the wrong answer
when y has a false value.  So it's one more thing to worry about when
using that construction.




More information about the Python-list mailing list