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

Andrew Koenig ark at
Sat Feb 8 02:33:07 CET 2003

Ian> Of course, personally, I would find this expression to be
Ian> horrible even without the missing else.  I would never put two
Ian> if's in a statement without parenthesis to make it entirely clear
Ian> how to parse it.

As long as every if has an else, no parentheses are needed.
That's one argument for a mandatory "else".  Another is that
the default value of None is not obvious.  For example, wouldn't
you be tempted to think that

        x = if y then z

means the same as

        if y:
            x = z

rather than

        if y:
            x = z
            x = None


Andrew Koenig, ark at,

More information about the Python-list mailing list