Another conditional expression candidate (PEP 308)

Samuele Pedroni pedronis at bluewin.ch
Mon Feb 10 00:09:05 EST 2003


"Andrew Koenig" <ark at research.att.com> ha scritto nel messaggio
news:yu99isvsk9oq.fsf at europa.research.att.com...
> Alan> Also, I think this would also be VERY confusing to new users.
> Alan> This would be legal syntax:
>
> Alan>     result = if cond: x else: y
>
> Alan> But this...
>
> Alan>     result = if cond:
> Alan>         x
> Alan>     else:
> Alan>         y
>
> Alan> ...would be illegal (it certainly is *now*, anyway). So to implement
> Alan> this would require changing the fact that "if" blocks are not
> Alan> expressions. Do I understand this correctly? Thanks.
>
> Why is this any more confusing than the fact that
>
>         result = x +
>                y +
>                z
>
> is illegal?

x+
 y+
 z

is not a valid statement.






More information about the Python-list mailing list