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

Thomas Lotze tl at gocept.com
Wed Sep 21 00:21:00 CEST 2005


Barry Warsaw wrote:

> I'm not so sure.  Once you start writing such a complicated thing, I think
> readability will favor just breaking the code out into traditional
> if-blocks.  I'd be happy enough with just a binary condition.

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.

-- 
Thomas




More information about the Python-Dev mailing list