In C/C++, comparison operators such as < > have higher priority than == does. This code will evaluate to true or 1:
if(3<4 == 2<3) { //3<4 == 2<3 will evaluate to true
...
}
But in Python, it seems wrong:
3<4 == 2<3 #this will evaluate to False in Python.
In Python, does every comparison operator have the same priority?
In Python, not only do comparison operators gave the same priority, they are treated specially (they chain rather than group). From the documentation:
In your case, the expression
is equivalent to
which is
Falsedue to the second clause.