2. Boolean Operations — and
, or
, not
¶
These are the Boolean operations, ordered by ascending priority:
Operation | Result | Notes |
---|---|---|
x or y |
if x is false, then y, else x | (1) |
x and y |
if x is false, then x, else y | (2) |
not x |
if x is false, then True ,
else False |
(3) |
Notes:
- This is a short-circuit operator, so it only evaluates the second
argument if the first one is
False
. - This is a short-circuit operator, so it only evaluates the second
argument if the first one is
True
. not
has a lower priority than non-Boolean operators, sonot a == b
is interpreted asnot (a == b)
, anda == not b
is a syntax error.