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

Paul Paterson hamonlypaulpaterson at houston.rr.com
Sat Feb 8 23:44:08 EST 2003


"James P. Rutledge" <jrut at spamcop.net> wrote in message
news:mailman.1044755725.30446.python-list at python.org...
> <Opinion>
>
> After seeing the mistakes that I and others have made with some of the
> current methods of trying to express a similar behavior to the
> conditional expression, also with the proposed syntax, and further
> considering the arguments made by others my opinion tends to be about
> neutral on the idea of adding conditional expressions.
>
> As far as the syntax of such a conditional expression if it were to be
> added, however, I strongly agree with those who feel that the least
> error prone syntax should read from left to right starting with the
> condition, then the expression to be used if the condition evaluates to
> True, then the expression to be used if the condition evaluates to
> False.  No matter what separators or keywords are used to identify the
> construct and its parts.
>
> <\Opinion>

I'm not sure if it has come up before, but what about the complete reverse?

val = sqrt(x) or 0 if x < 0

+ keeps options and condition separate
+ reads left to right
+ important bits (usual value and condition) are at the ends where you can
find them
+ looks a little bit like the current idiom
- most of the same objections to the PEP form









More information about the Python-list mailing list