Python evaluates a and b by evaluating a first; if a is false, the result is false and b is not evaluated at all. It evaluates a or b by evaluating a first; if a is true, the result is true and b is not evaluated. This is short-circuit evaluation.
书籍暂未推出简体中文版——当前显示英文版。
Computer Science · 术语表
什么是 Short-circuit evaluation?
In a && b and a || b, the operand a is evaluated first; b is evaluated only when a does not already decide the result (a true for &&, false for ||). This is short-circuit evaluation. A test such as n != 0 && 10 / n > 1 relies on it to avoid dividing by zero.
a + b * c > d && e != 0: * binds tighter than +, which binds tighter than >, and && is loosest. The left subtree of && is evaluated first, and the right one only if the left is true.