Python/Tutorial/Basic Types and Operators/bool

From Jonathan Gardner's Tech Wiki
Jump to: navigation, search

The bool type represents boolean values---True and False.

Using the bool() function, you can convert almost anything into a bool. The rules are:

  • None, 0 and 0.0 is False.
  • Empty lists, sets, and dicts are False.
  • Special kinds of objects may be True or False, if they make the distinction.
  • Everything else is True.