From the docs:
Note that comparisons, membership tests, and identity tests, all have the same precedence and have a left-to-right chaining feature as described in the Comparisons section.
in
and ==
are membership and comparison operators respectively.
From Comparisons:
... expressions like a < b < c
have the interpretation that is conventional in mathematics:
[...]
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 (but in both cases z
is not evaluated at all when x < y
is found to be false).