Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / Python

Keyword None

None is the sole instance of NoneType and often represents an absent result.

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

Syntax

value is None

None is the sole instance of NoneType and often represents an absent result.

A function falling off its end returns None. Use is None to test this singleton while preserving valid false-like values such as 0 or an empty string.

Assigning to the keyword None is a syntax error.

Examples

def optional(value):
    if value is not None:
        return value
for item in (None, 0, ""):
    result = optional(item)
    print(result is None, repr(result))

Result

True None
False 0
False ''

Assigning to the keyword None is a syntax error.

Sources