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

Aahz aahz at pythoncraft.com
Sat Feb 8 10:27:58 EST 2003


In article <yu9965rubyi6.fsf at europa.research.att.com>,
Andrew Koenig  <ark at research.att.com> wrote:
>
>Paul> You know, if the inspiration for this syntax (condition in the
>Paul> middle) is list comprehensions, maybe the thing can be improved
>Paul> by requiring parentheses around the expression:
>
>Paul>   (x if is_special(x) else y)
>
>Paul> For some reason I find that clearer than the same thing without
>Paul> the parens.
>
>I thought of that too, but would hate to have to explain that the
>compiler rejected
>
>        f(x if is_special(x) else y)
>
>because you didn't write
>
>        f((x if is_special(x) else y))

How is that any different from tuples?  At least this gives an explicit
error message.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

Register for PyCon now!  http://www.python.org/pycon/reg.html




More information about the Python-list mailing list