Operator precedences
Erik Max Francis
max at alcyone.com
Tue Feb 25 19:41:56 EST 2003
Jesper Hansen wrote:
> These both evaluate to true, so the order does not seem to be fixed;
> (3 < 2 < 1) == (3 < (2 < 1))
> (1 < 2 < 3) == ((1 < 2 ) < 3)
>
> What am I missing?
Probably that Python's relational operators can be chained. If you
write
a ? b ? c
where ? is one of the relational operators, this has the same meaning as
a ? b and b ? c
In short, neither of your examples is correct. (And no, 3 < 2 < 1 does
not evaluate to True.)
--
Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
__ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/ \ The more one is hated, I find, the happier one is.
\__/ Louis-Ferdinand Celine
Bosskey.net / http://www.bosskey.net/
A personal guide to online multiplayer first person shooters.
More information about the Python-list
mailing list