Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / Python

Operator ==

Compares values using the equality protocol.

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

Syntax

left == right

Compares values using the equality protocol.

Use equality for comparing values such as independently parsed measurements or lists. Built-in lists compare their elements in order; their object identities need not match.

A custom equality method can return a specialized result. If both objects decline equality comparison, identity supplies the fallback. Numeric NaN is a special case that does not equal itself.

Equal values can have different types when their types define compatible numeric comparisons.

Syntax

left == right

__eq__ · NotImplemented

Worked example

[1, 2] == [1, 2] → True
1 == 1.0 → True
float("nan") == float("nan") → False

Examples

print([2, 3] == [2, 3])
print(1 == True)

Result

True
True

Equal values can have different types when their types define compatible numeric comparisons.

Sources