CKTIS / Python
NoneType
Het type van het unieke object None is beschikbaar als types.NoneType en type(None).
Versie: Python 3.14; repository image, production runtime not attested
Syntax
from types import NoneTypeHet type van het unieke object None is beschikbaar als types.NoneType en type(None).
Een aanroep zonder argumenten levert hetzelfde object op. De test is None onderscheidt afwezigheid van onware waarden zoals nul of de lege tekenreeks.
Een unieannotatie kan None uitdrukkelijk toelaten.
Voorbeelden
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))
Resultaat
True True ['absent', 'int', 'str'] False
Een unieannotatie kan None uitdrukkelijk toelaten.