On this page
None
Prev: False | Up: __builtins__ | Next: NotImplemented
Rel: True, False, Ellipsis, NotImplemented, copyright
Ref: docs.python.org — None
Tags: #public #python3 #builtins
Import & Availability
# Built-in (available globally without import)
from builtins import None
Overview & Signature
None -> NoneType
The type of the None singleton.
Usage
def find_user(uid: int) -> str | None:
return "Ada" if uid == 1 else None
assert find_user(2) is None
assert find_user(1) is not None
Gotchas
- Always compare with
is None/is not None, never== None(custom__eq__methods can override==). - Singleton: Every
Nonein a Python process is the exact same object.
REPL Inspect
help(None)
Linked from
- tuts/python3/__builtins__
- tuts/python3/__builtins__/__builtins__
- tuts/python3/__builtins__/copyright
- tuts/python3/__builtins__/credits
- tuts/python3/__builtins__/Ellipsis
- tuts/python3/__builtins__/exit
- tuts/python3/__builtins__/False
- tuts/python3/__builtins__/help
- tuts/python3/__builtins__/license
- tuts/python3/__builtins__/NotImplemented
- tuts/python3/__builtins__/quit
- tuts/python3/__builtins__/True
Related notes
- tuts/python3/__builtins__/__builtins__ Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/copyright Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/Ellipsis Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/False Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/NotImplemented Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/True Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__ links to this page; shared tags: #builtins
- tuts/python3/__builtins__/credits links to this page; shared tags: #builtins
- tuts/python3/__builtins__/exit links to this page; shared tags: #builtins
- tuts/python3/__builtins__/help links to this page; shared tags: #builtins