PEP 308: Alternative conditional operator forms
Erik Max Francis
max at alcyone.com
Mon Feb 10 19:57:49 EST 2003
Robin Munn wrote:
> Almost, but not *quite*, what I wanted to suggest. I propose:
>
> (x if C else y) # Parentheses are *required*
>
> This is identical to the format proposed in PEP 308 with the exception
> that parentheses are required around the ternary expression.
The immediate reaction to this is that it doesn't seem fair in cases
like:
f((x if C else y))
(without the doubled parentheses, it would be illegal). If you want to
special-case that one, then the grammar gets more complicated and
eventually you start wondering why the parentheses should be required
anyway.
Use parentheses for clarity, sure. _Require_ them, I don't see.
--
Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
__ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/ \ Whoever contends with the great sheds his own blood.
\__/ Sa'di
Polly Wanna Cracka? / http://www.pollywannacracka.com/
The Internet resource for interracial relationships.
More information about the Python-list
mailing list