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

Ian Bicking ianb at colorstudy.com
Fri Feb 7 19:54:01 EST 2003


On Fri, 2003-02-07 at 17:28, Andrew Koenig wrote:
> But then you have to figure out the meaning of
> 
>         a if b if c else d
> 
> Does it mean
> 
>         (a if b) if c else d
> 
> which would be equivalent to
> 
>         (a if b else None) if c else d
> 
> or does it mean
> 
>         a if (b if c) else d
> 
> which would be equivalent to
> 
>         a if (b if c else none) else d

I would expect it to mean

    a if (b if c else d) else None

It seems obvious to me that this is the proper interpretation.  But I
can't say why, which certainly implies that else needs to be required.

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

-- 
Ian Bicking  ianb at colorstudy.com  http://colorstudy.com
4869 N. Talman Ave., Chicago, IL 60625  /  773-275-7241
"There is no flag large enough to cover the shame of 
 killing innocent people" -- Howard Zinn





More information about the Python-list mailing list