PEP 308: Precendence of "a then b else c"

sik0fewl xxdigitalhellxx at hotmail.com
Thu Feb 13 09:38:42 EST 2003


Anders J. Munch wrote:
> "Raymond Hettinger" <vze4rx4y at verizon.net> wrote:
> 
>>The leading options on the table are:
>>
>>*     <cond> then <expr1> else <expr2>
> 
> 
> What's the precedence of this thing?
> 
> For example, what do each of these mean:
The way my mind parses it..
>    a + b then c else d
(a+b) then c else d
>    a then b else c + d
a then b else (c+d)
>    a and b then c else d
(a and b) then c else d
>    a then b else c and d
a then b else (c and d)
>    a, b then c else d
(a,b) then c else d
>    a then b else c, d
a then b else (c,d)
>    lambda: a then b else c
... parser error? :)
(lambda: a) then b else c

Basically what I've just said is that it has (or should have) a very low 
precedence.

It should definitely have low precedence before the 'then', otherwise 
all comparisons would have to be enclosed in ().

As for expressions trailing after the 'else'.. it just seems like a good 
idea. For uniformity.

--
Ryan





More information about the Python-list mailing list