How do I use a Boolean in Python?

checker = None 

if some_decision:
    checker = True

if checker:
    # some stuff

[Edit]

For more information: http://docs.python.org/library/functions.html#bool

Your code works too, since 1 is converted to True when necessary.
Actually Python didn’t have a boolean type for a long time (as in old C), and some programmers still use integers instead of booleans.

Leave a Comment