Is Python really pulling a syntactic trick?
I think < is simply left associative: True < 4 is True.
Similarly, I think > is right associative. (50 > 30) > 10 does not hold, but 50 > (30 > 10) holds.
I think < is simply left associative: True < 4 is True.
Similarly, I think > is right associative. (50 > 30) > 10 does not hold, but 50 > (30 > 10) holds.
Comparisons can be chained arbitrarily, e.g., x < y <= z is equivalent to x < y and y <= z, except that y is evaluated only once.
randall@gulch:~$ python -c 'print 1 < 2 < 4'
True
randall@gulch:~$ python -c 'print 1 < 5 < 4'
False >>> True + True
2
Simple left-associativity would also make 3<4<2 evaluate to True.