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

Erik Max Francis max at
Sat Feb 8 11:52:08 CET 2003

Paul Rubin wrote:

> You know, if the inspiration for this syntax (condition in the middle)
> is list comprehensions, maybe the thing can be improved by requiring
> parentheses around the expression:
>   (x if is_special(x) else y)
> For some reason I find that clearer than the same thing without the
> parens.

Fortunately, whether they're required or not, you can always insert them
yourself as a matter of style.  I don't think they should be required
but imagine myself using surrounding parentheses often.

 Erik Max Francis / max at /
 __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ If anything is sacred, the human body is sacred.
\__/ Walt Whitman
    ZOE /
 A simple Python OpenGL rendering engine.

More information about the Python-list mailing list