Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / Python

Operator is not

Tests whether references designate distinct objects.

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

Syntax

left is not right

Tests whether references designate distinct objects.

Use an identity exclusion to distinguish a missing-value sentinel from a different object whose contents happen to compare equal. The answer is always Boolean.

The operation inverts the identity test directly. It does not call a user-defined inequality method; two independently allocated empty lists therefore pass this test.

Binding another name to a list creates an alias for the same list.

Syntax

left is not right

is not · id(object)

Worked example

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

Examples

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

Result

True
False

Binding another name to a list creates an alias for the same list.

Sources