python中表达式(0==0<1<2<3>2>1>0==0)的结果是如何计算出来的?

How is the result of the expression (0==0<1<2<3>2>1>0==0) calculated in python?

请解释表达式(0==0<1<2<3>2>1>0==0)的结果是如何在python中计算出来的。

与大多数语言不同,Python 支持链式比较。所以如下:

0==0<1<2<3>2>1>0==0

相当于:

0==0 and 0<1 and 1<2 and 2<3 and 3>2 and 2>1 and 1>0 and 0==0

你可以阅读它 here。相关摘录是:

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).