Python Language Boolean Operators Short-circuit evaluation

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

Python minimally evaluates Boolean expressions.

>>> def true_func():
...     print("true_func()")
...     return True
... 
>>> def false_func():
...     print("false_func()")
...     return False
... 
>>> true_func() or false_func()
true_func()
True
>>> false_func() or true_func()
false_func()
true_func()
True
>>> true_func() and false_func()
true_func()
false_func()
False
>>> false_func() and false_func()
false_func()
False


Got any Python Language Question?