[Python-Dev] conditional expressions?

Guido van Rossum guido@python.org
Mon, 15 Oct 2001 18:02:31 -0400


> Because the conditional *ends* in something that "pulls in" all
> following binary operators and their operands until it hits a ")", 
> I find it safer not to let it accept an operator at the front.

To explain this perhaps a bit better, the 'else' keyword acts as the
right side of a low-priority binary operator with respect to the
expression that follows.  It would be unpleasant if the 'if' keyword
acted as the left side of a *high*-priority operator to the expression
that preceeds it.  Again, think of what this would mean:

    (3 * if x then y else z + 4)

--Guido van Rossum (home page: http://www.python.org/~guido/)