Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk4 min

Booleans in Python: True, False and How to Check Them

Python has two Boolean constants, True and False. This guide explains truthiness, identity, type membership and equality checks, and shows which one to use for each intent.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To check whether a variable holds a Boolean, pick the test that matches what you need. Use if value: when any truthy value should pass. Use value is True when only the True singleton should pass. Use isinstance(value, bool) to ask whether a value is a Boolean type instance, and type(value) is bool when you need the exact built-in type. Python’s Boolean constants are capitalized, so True and False work, while lowercase true and false do not.

The two Boolean values

Python’s built-in bool type has exactly two constant instances, True and False. The Python Software Foundation’s Built-in Types reference, in its Boolean Type section (checked against the Python 3.14.7 documentation on 2026-10-07), states this directly. Because the type has only two instances, every bool value you will meet is one of these two singletons.

As an Amazon Associate I earn from qualifying purchases.

Lowercase true and false are not Python constants. In a script they raise a NameError unless you have defined variables with those names, and that is a common source of confusion for people coming from JSON or JavaScript.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Truthiness: what if and while actually test

An if or while condition does not require the tested object to be literally True or False. Python evaluates the object’s truth value. This is why if items: works for lists, strings and numbers.

Default truth rules

By default, an object is true. An object is false only when its class defines __bool__() to return False, or defines __len__() to return zero. The official docs list these falsy built-in values:

  • None
  • False
  • numeric zero, such as 0, 0.0 and 0j
  • empty strings and empty built-in collections, such as "", [], (), {} and set()
items = [3, 1, 2]

if items:            # True: the list is non-empty
    print("has data")

if items is True:    # False: items is a list object, not the True singleton
    print("never reached")

The two conditions in that example ask different questions. The first asks whether the list has content. The second asks whether the name refers to the True object itself. For most conditions, the first is what you want.

Four checks, four different questions

Each check below answers one question. Choosing the right one matters more than any difference in speed; the official sources do not establish a performance difference between them, so select by intent.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Truthiness: if value:

Use this when any value that counts as true should pass. It accepts True, but also non-empty strings, non-zero numbers and non-empty containers. It is the idiomatic choice for most conditions.

Identity: value is True

Identity compares object identity, not value. value is True is true only when value refers to the True singleton. Use it when a value that merely behaves like true, such as 1, must be rejected.

flag = 1

if flag:             # True: 1 is truthy
    print("truthy")

if flag is True:     # False: 1 is an int, not the True singleton
    print("exactly True")

Type membership: isinstance(value, bool)

isinstance() returns true when the value is an instance of bool, including instances of any subclass of bool. It answers “is this a Boolean?” and does not care about the value being True or False.

is_boolean = isinstance(False, bool)   # True
is_boolean = isinstance(0, bool)       # False

Exact built-in type: type(value) is bool

Use type(value) is bool when you need the exact built-in type and want to exclude subclasses. This is stricter than isinstance(), and is rarely needed outside validation code or serialisation boundaries.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Equality: value == True

Equality compares values, not types or identity. In Python, 1 == True and 1.0 == True both evaluate to True. This makes == True a source of bugs when integers are mixed with Booleans, and it is usually less clear than the intent-specific forms above.

Why bool counts as an integer

bool is a subclass of int, so isinstance(True, int) is true. In numeric contexts, False and True behave like 0 and 1, so True + True evaluates to 2. The official documentation discourages relying on this behaviour in new code.

This matters when you validate input. If a function expects a number and you check only with isinstance(value, int), Booleans pass that check. If you need to reject them, test for bool first:

def require_int(value):
    if isinstance(value, bool) or not isinstance(value, int):
        raise TypeError("expected an int, not bool")
    return value
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Logical operators return operands

and and or use short-circuit evaluation. They return one of their operands, which may not be a Boolean. not always returns True or False.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
name = "" or "guest"      # "guest": the first operand is falsy
limit = 0 and 10          # 0: the first operand is falsy, so it is returned
blocked = not name        # False: "guest" is truthy

The official docs recommend and, or and not for logical operations, rather than the bitwise operators &, | and ^. The bitwise forms belong to integer and set operations, and mixing them into conditions makes intent harder to read.

Common mistakes to avoid

  • Writing if flag == True: when if flag: expresses the same intent more clearly.
  • Writing if items is True: when you meant to test whether the collection is non-empty.
  • Assuming isinstance(x, int) excludes Booleans. It does not.
  • Using lowercase true or false in Python code.

Sources and version notes

The statements above come from the Python Software Foundation’s official documentation for Python 3.14, checked on 2026-10-07 against the 3.14.7 release. The Boolean Type section of Built-in Types contains the two-constants statement quoted in this article. The identity behaviour described here is covered in the Identity comparisons section of Expressions in the same documentation set. Language documentation can change between releases, so confirm version-sensitive details against the Python docs for the version you run.

“The bool type has exactly two constant instances: True and False.”

Python Software Foundation, Built-in Types — Python 3.14.7 documentation, Boolean Type section.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

“

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.