CKTIS / Python
Operator !=
Tests whether two values compare unequal.
Version: Python 3.14; repository image, production runtime not attested
Syntax
left != rightTests whether two values compare unequal.
Use inequality to detect a changed value rather than a changed object reference. Two independent lists holding equal elements normally compare equal.
A class may define inequality explicitly. The default object implementation delegates to equality and inverts a supported result. NaN is unequal even to itself.
Different numeric types can represent equal values and thus yield a false inequality test.
Syntax
left != right
__ne__, __eq__ · NotImplemented
Worked example
[1, 2] != [2, 1] → True
1 != True → False
float("nan") != float("nan") → True
[1, True] != [True, 1] → False
x = float("nan")
x != x → True
[x] != [x] → False
[x] != [float("nan")] → True
Examples
print([2, 3] != [3, 2])
print(1 != True)
Result
True False
Different numeric types can represent equal values and thus yield a false inequality test.