Glossary

None

None is Python's built-in constant representing "no value" or "nothing here." It is the sole instance of the NoneType class — a true singleton, meaning there is exactly one None object in any Python process. Because of this, the idiomatic way to check for None is if x is None (identity check) rather than if x == None (equality check).

Functions that do not explicitly return a value implicitly return None. This makes None ubiquitous: it is the default return value, the conventional default for optional parameters, and a common sentinel indicating "not yet initialised" or "not found." For example, dict.get(key) returns None if the key is absent, and re.search() returns None if the pattern does not match.

None is falsy in boolean contexts, so if result: will fail if result is None. However, it will also fail if result is 0, "", or []. When you specifically need to distinguish None from other falsy values, always use is None. In type hints, None as a return annotation means the function returns nothing, and Optional[X] (or X | None in Python 3.10+) means the value can be either type X or None.

Related terms: Boolean, Type Hint

Discussed in:

This site is currently in Beta. Please email Chris Paton (cpaton@gmail.com) with any suggestions, questions or comments.