News for hackers. Stuff that matters.
Re:Many programming languages have infix expressions, but ge... by enum on Sunday January 31, 2010 @06:58PM (#1091379)
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.

Re:Many programming languages have infix expressions, but ge... by jedi_stannis on Sunday January 31, 2010 @07:01PM (#1091383)
Yes it is really pulling a syntactic trick and not comparing against bools. From the docs:

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.

http://docs.python.org/reference/expressions.html#notin

Re:Many programming languages have infix expressions, but ge... by randallsquared on Sunday January 31, 2010 @07:42PM (#1091443)

    randall@gulch:~$ python -c 'print 1 < 2 < 4'
    True
    randall@gulch:~$ python -c 'print 1 < 5 < 4'
    False
Re:Many programming languages have infix expressions, but ge... by beza1e1 on Monday February 01, 2010 @02:09AM (#1091957)
In Python True==1, unfortunatelly.

  >>> True + True
  2
Simple left-associativity would also make 3<4<2 evaluate to True.