Python Language Tutorial => Truth Values
Example
The following values are considered falsey, in that they evaluate to False when applied to a boolean operator.
- None
- False
0, or any numerical value equivalent to zero, for example0L,0.0,0j- Empty sequences:
'',"",(),[] - Empty mappings:
{} - User-defined types where the
__bool__or__len__methods return 0 orFalse
All other values in Python evaluate to True.
Note: A common mistake is to simply check for the Falseness of an operation which returns different Falsey values where the difference matters. For example, using if foo() rather than the more explicit if foo() is None