In Python, a function that doesn't explicitly return anything returns None
. None
is considered false in a boolean context.
In the second example, g
doesn't run because the and
operator short-circuits. f
's result was false, so g()
doesn't need to be evaluated, as its result won't change the result of the whole and
expression.
Similarly, in the third example, since f()
was false, the right side of the and
doesn't need to be evaluated, so g
and h
don't run.