Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / Python

Operator is

Tests whether two references designate the same object.

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

Syntax

left is right

Tests whether two references designate the same object.

Use identity for sentinel objects, including the singleton used for a missing result. The interpreter checks object identity directly and returns a Boolean.

A class cannot redefine this operator through a comparison method. Caching of some immutable objects makes identity unsuitable for comparing ordinary numeric or text values.

Copying a list preserves its contents but creates a distinct outer object.

Syntax

left is right

is · id(object)

Worked example

a = []; b = a; c = a.copy()
a is b → True
a is c → False

Examples

records = [8]
alias = records
print(alias is records)
print(list(records) is records)

Result

True
False

Copying a list preserves its contents but creates a distinct outer object.

Sources