Home > Articles > Open Source > Python

  • Print
  • + Share This
Like this article? We recommend

Bool

It used to very common to see Python code that declared TRUE and FALSE to be 1 and 0, respectively, at the top of every file. Or, it might have been True and False or true and false. Now we know Guido's preferred capitalization: True and False have been added as constants. Numerically, they still behave as 0 and 1, but we won't have to declare them anymore.

The built-in function bool() can be used to convert anything that can be tested for truth into a Boolean.

  • + Share This
  • 🔖 Save To Your Account