is operator

The operator that tests whether two names refer to the very same object.

In more detail

a is b is True only when a and b are one object; a == b compares values instead. For a class with no __eq__, == falls back to identity, so two separately created objects are never equal. Use is for None checks, as in x is None.

Example

x = [1, 2]
y = [1, 2]
print(x == y, x is y)   # True False

Related terms

Taught in

References

Certification courses