PEP 308: Alternative conditional operator forms

Tim Peters tim.one at comcast.net
Mon Feb 10 20:19:45 EST 2003


[Erik Max Francis]
> 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.

It seems little-known that Guido implemented conditional expressions for
Python about two years ago:

    http://www.python.org/sf/471421

One of his patch comments there:

    It's hairier than expected because I'm trying to require you to
    put parentheses around it in some cases but not in others.

See the patch for more.






More information about the Python-list mailing list