Boolean¶
Boolean Values¶
Boolean: the last of the simple ones
>>> 1 < 2
True
>>> 'X' == 'U'
False
|
|
Boolean Operators¶
Usual operators …
L and R
:True
if bothL
andR
evaluate toTrue
L or R
:True
ifL
orR
evaluate toTrue
not X
:True
ifX
evaluates toFalse
Short circuit evaluation: operands are only evaluated until the expression’s value is clear
L and R
: ifL
isFalse
, then the expression cannot becomeTrue
anymore ⟶R
not evaluatedL or R
: ifL
isTrue
, …⟶ important when
L
,R
are functions with side effects