Use value is None to check whether a variable is specifically None. Use if not value when any false-valued value—including None, False, zero, or an empty container—should take the same path. These checks answer different questions.
Choose the check that matches what “empty” means
| Check | What it matches | Use it when |
|---|---|---|
value is None |
Only the None singleton |
None alone means missing or unset |
not value |
None, False, numeric zero, empty built-in sequences and collections, and objects that define false truth behavior |
All false-valued inputs should be treated alike |
The distinction is about meaning, not speed. Python defines None as a single object commonly used to represent the absence of a value, so test for it by identity: value is None. Python Built-in Types documentation and the language reference on identity comparisons describe these rules.
Check only for None
if value is None:
handle_missing()
This leaves valid false-valued inputs alone. For example, if 0, False, '', [], or {} are meaningful values in your program, an explicit None check will not mistake them for missing data.
Prefer is None to == None. The former asks whether value is the same object as the None singleton; equality comparisons can follow an object’s custom equality behavior.
#1 Best Overall
Check for any false-valued value
if not value:
handle_empty_or_false_value()
In a condition, Python tests an object’s truth value. None, False, numeric zero, and empty built-in sequences and collections are false. By default, other objects are true unless their class defines __bool__() to return False or __len__() to return zero. See the official truth-value testing documentation.
That means if not value is broader than a check for an empty string or container. Use it only when the program should handle every false-valued case the same way.
Rank #2
Check for an empty string or blank text
Exactly an empty string
if value == "":
handle_empty_string()
This tests for the empty string specifically; it does not classify None or numeric zero as an empty string.
Whitespace-only text
if value is not None and not value.strip():
handle_blank_text()
A string containing spaces or other whitespace is nonempty, so it is truthy. Calling strip() makes a whitespace-only string count as blank. This expression assumes value is either None or a string; validate or convert other input types as your application requires.
Recommended Free Tools
Use a fallback without discarding zero or False
This expression uses truthiness, so it selects fallback for any false-valued value:
result = value or fallback
If only None should trigger the fallback, write the condition explicitly:
result = fallback if value is None else value
Python’s or operator returns one of its operands: it evaluates the left operand’s truth value and returns the fallback when that operand is false. The language reference on Boolean operations specifies this behavior.
Quick Recap
Best Value
Common mistakes to avoid
- Treating “false” as synonymous with “not provided.”
if not valuealso catches zero,False, and empty values. Usevalue is Nonewhen those may be valid. - Using equality for a None check. Write
value is Noneto test the singleton directly. - Assuming custom objects use ordinary emptiness rules. A class can control its truth value through
__bool__()or__len__(). - Expecting whitespace to be an empty string. Whitespace makes a string nonempty; strip it explicitly if your rule treats blank text as empty.
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.




