Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorsTo 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.
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.
#1 Best Overall
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:
NoneFalse- numeric zero, such as
0,0.0and0j - empty strings and empty built-in collections, such as
"",[],(),{}andset()
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.
Rank #2
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.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minutePC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Equality: 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.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.
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.
Best Value
Common mistakes to avoid
- Writing
if flag == True:whenif 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
trueorfalsein 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
booltype has exactly two constant instances:TrueandFalse.”
Python Software Foundation, Built-in Types — Python 3.14.7 documentation, Boolean Type section.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →Quick Recap
“
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.




