[Python-Dev] Adding a conditional expression in Py3.0

Barry Warsaw barry at python.org
Wed Sep 21 00:49:27 CEST 2005

On Tue, 2005-09-20 at 18:21, Thomas Lotze wrote:

> Nothing prevents you from spreading the code over multiple lines, like so:
> x = (if a then b
>      elif c then d
>      else e)
> or even
> x = (if a then
>         b
>      elif c then
>         d
>      else
>         e
>     )
> especially as there are going to be parentheses around the whole thing
> anyway. From a readability point of view, this is no different from
> if-statement blocks, and the matter is IMO not worth dumbing down an
> if-expression thingy as compared to its if-statement companion.

I guess that's my point.  To me, your latter is actually worse than

if a:
    x = b
elif c:
    x = d
    x = e

I think the conditional stuff gets the most bang for the buck in
situations like:

d[foo] = if a then b else c


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 307 bytes
Desc: This is a digitally signed message part
Url : http://mail.python.org/pipermail/python-dev/attachments/20050920/561d120c/attachment.pgp

More information about the Python-Dev mailing list