PEP 308: Alternative conditional operator forms -- Corner Case solved

Terry Reedy tjreedy at udel.edu
Sat Feb 15 02:26:35 CET 2003


"Andrew Koenig" <ark at research.att.com> wrote in message
news:yu99smusakrf.fsf at europa.research.att.com...
> Terry> Given this understanding (which I realize I should explain
> Terry> further), it is straightforward and obvious that their
> Terry> combination forms a conditional selection expression, just as
> Terry> the combination a+b*c forms an arithmetic expression.
>
> Yes, it is straightforward and obvious.
>
> It is also wrong.
>
> The reason it is wrong is the result when a is true and b is false.
> If (a and b or c) were really a conditional selection expression,
> then you would expect the result to be b.  In fact, it is c.
>
>         >>> 1 and 3 or 7
>         3
>         >>> 1 and 0 or 7
>         7
>
> --
> Andrew Koenig, ark at research.att.com,
http://www.research.att.com/info/ark






More information about the Python-list mailing list