To expand Blender's explanation a bit further, the or
operator has something else built-in:
<expression A> or <expression B>
This will evaluate expression A
first; if it evaluates to True
then expression A
is returned by the operator. So 5 or <something>
will return 5
as 5
evaluates to True
.
If expression A
evaluates to False
, expression B
is returned. So 0 or 5
will return 5
because 0
evaluates to False
.
Of course you can chain this as much as you want:
<expr 1> or <expr 2> or <expr 3> or ... or <expr n>
In general, or
will return the first expression which evaluates to True
, but keep its original value. If there is no expression that evaluates to True
, it will simply return the last expression (which evaluates to False
).
The and
operator works in a similar but inversed way. It will return the first expression which does evaluate to False
, but keep its original value. If there is no expression that evaluates to False
, it will simply return the last expression (which will evaluate to True
).
As an example, both 0 and 5
and 5 and 0
will return 0
because 0
evaluates to False
, but 2 and 3
will return 3
because 3
is the last expression and everything evaluates to True
.
In any way (to come back to the question): All expressions are evaluated from left to right, and if a rule from above allows it, further expressions will not be touched.