For review: PEP 308 - If-then-else expression
Evan
evan at 4-am.com
Sun Feb 9 01:24:47 EST 2003
Jamie Guinan wrote:
> Generally, the syntax (including result) would be:
>
> <result> = case:
> <cond1>:
> <expr1>
> <cond2>:
> <expr1>
> ...
> <condN>:
> <exprN>
>
> If it falls of the end, the result is None.
This is a pretty unlikely candidate for a keyword, since it even appears
in the standard libraries, and using indentation in an expression is
probably a non-starter too. I've been pushing a somewhat similar idea,
with several possibilities for syntactic details:
(if cond1: expr1 elif cond2: expr2 ... else: exprN)
{if cond1: expr1, cond2: expr2, ... 1: exprN}
if:(cond1, expr1, cond2, expr2, ..., exprN)
In any case, existing conditional keyword(s) + grouping delimiters to
help the parser (and the reader).
Cheers,
Evan @ 4-am
More information about the Python-list
mailing list