Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / Python

NoneType

The type of the singleton None is available as types.NoneType and also via type(None).

Version: Python 3.14; repository image, production runtime not attested

Syntax

from types import NoneType

The type of the singleton None is available as types.NoneType and also via type(None).

Calling this type without arguments returns the same singleton. Testing identity with None distinguishes an absent value from false-like values such as zero or an empty string.

A parameter annotation can explicitly allow None as one member of a union.

Examples

from types import NoneType
def kind(x: int | str | None) -> str:
    return "absent" if x is None else type(x).__name__
print(type(None) is NoneType, NoneType() is None)
print([kind(x) for x in (None, 0, "")])
print(isinstance(False, NoneType))

Result

True True
['absent', 'int', 'str']
False

A parameter annotation can explicitly allow None as one member of a union.

Sources