Introduction
In Python the boolean test has the following rules:
- All objects have an inherent Boolean true or false value.
- Any nonzero number or nonempty object is true.
- Zero numbers, empty objects, and None are considered false.
- Comparisons and equality tests are applied recursively to data structures.
- Comparisons and equality tests return True or False (custom versions of 1 and 0).
- Boolean and and or operators return a true or false operand object.
- Boolean operators stop evaluating (short circuit) as soon as a result is known.
Related Topic