PEP 308: Alternative conditional operator forms -- Corner Case solved
Andrew Koenig
ark at research.att.com
Wed Feb 12 23:04:52 EST 2003
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