I'm wondering how Python parses:
not a < b < c
It seems to interpret this as:
not (a < b < c)
as opposed to (not a) < b < c
This question explains grouping vs chaining: Python comparison operators chaining/grouping left to right? but what are the rules for the precedence of chained comparisons?
It's strange to me that not
, <
and >
have the same precedence, but not a < b < c
parses as not (a < b < c)
while -a < b < c
parses as (-a) < b < c
.
I tested this by evaluating not 2 > 1 > 2
in Python 2.7.