What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Use value is not None to check that a Python variable is not None:
if value is not None:
# value exists, even if it is 0, False, or ""
...
Python’s missing-value singleton is spelled None, not “null.” The right condition depends on whether you mean “not None” or “not empty/false.”
As an Amazon Associate I earn from qualifying purchases.
Check specifically whether a value is not None
Use the identity test is not None when only None should count as absent:
if value is not None:
print("A value was provided")
This condition also passes for 0, False, an empty string (""), and an empty list ([]). Those values are not None, even though some are false in a Boolean context.
#1 Best Overall
To check the opposite—whether a value is exactly None—write value is None.
Use a truthiness check only when falsey values also count as missing
if value: checks whether a value is truthy, not whether it is different from None. It rejects None, False, numeric zero, and empty strings and containers. Use it when that broader behavior is what you want; Python’s documentation lists values treated as false in Boolean contexts in the expressions reference.
Rank #2
For example, this function treats an empty string as a supplied name:
def greet(name=None):
if name is not None:
print(f"Hello, {name}")
else:
print("Hello, guest")
If an empty string should instead trigger the guest greeting, use a truthiness check deliberately:
def greet(name=None):
if name:
print(f"Hello, {name}")
else:
print("Hello, guest")
Why use is instead of ==
Prefer value is None and value is not None over value == None and value != None. Python’s is and is not operators test object identity; None is a singleton. The Python language reference describes identity comparisons, and PEP 8 recommends using is or is not for comparisons to singletons such as None.
Choose the condition that matches your intent
| What you want to test | Condition | What it accepts |
|---|---|---|
| Value is not the None singleton | value is not None |
0, False, empty strings and containers, and other non-None values |
| Value is the None singleton | value is None |
Only None |
| Value is truthy | if value: |
Values that are not falsey; rejects None, False, zero, and empty strings and containers |
PEP 8 specifically warns that a truthiness test can be wrong when checking whether an optional argument with a default of None was given a different value: the caller may have supplied a valid but falsey value.
Quick Recap
Best Value
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.
Free tools Windows power users keep installed
One-click scans. No signup required.




