I think if I understand correctly, a <> b
is the exact same thing functionally as a != b
, and in Python not a == b
, but is there reason to use <>
over the other versions? I know a common mistake for Python newcomers is to think that not a is b
is the same as a != b
or not a == b
.
<>
, or is it exactly the same functionally?It means not equal to. It was taken from ABC (python's predecessor) see here: x < y, x <= y, x >= y, x > y, x = y, x <> y, 0 <= d < 10. Order tests ( <> means 'not equals')
The != operator compares the value or equality of two objects, whereas the Python is not operator checks whether two variables point to the same object in memory.
<>
in Python 2 is an exact synonym for !=
-- no reason to use it, no disadvantages either except the gratuitous heterogeneity (a style issue). It's been long discouraged, and has now been removed in Python 3.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With