Operator precedences

Andrew Koenig ark at research.att.com
Wed Feb 26 04:10:15 CET 2003


Jesper> In what order are compare operators evaluated?  According to
Jesper> http://www.python.org/doc/current/ref/summary.html they all
Jesper> have the same precedence and are evaluated from right to left,
Jesper> but this does not seem to true in python 2.2.2.

Jesper> These both evaluate to true, so the order does not seem to be fixed;
Jesper> (3 < 2 < 1)  ==  (3 < (2 < 1))
Jesper> (1 < 2 < 3)  ==  ((1 < 2 ) < 3)

Jesper> What am I missing?

For example,

        (3 < 4 < 5) != (3 < (4 < 5))

-- 
Andrew Koenig, ark at research.att.com, http://www.research.att.com/info/ark




More information about the Python-list mailing list