Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python ( or general programming ). Why use <> instead of != and are there risks?

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.

  1. Do similar misconceptions occur with <>, or is it exactly the same functionally?
  2. Does it cost more in memory, processor, etc.
like image 234
orokusaki Avatar asked Feb 22 '10 16:02

orokusaki


People also ask

What is the meaning of <> in Python?

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')

What is the difference between != and is not in Python?

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.


1 Answers

<> 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.

like image 151
Alex Martelli Avatar answered Oct 04 '22 22:10

Alex Martelli