What does `<>` mean 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’)

I believe ABC took it from Pascal, a language Guido began programming with.

It has now been removed in Python 3. Use != instead. If you are CRAZY you can scrap != and allow only <> in Py3K using this easter egg:

>>> from __future__ import barry_as_FLUFL
>>> 1 != 2
  File "<stdin>", line 1
    1 != 2
       ^
SyntaxError: with Barry as BDFL, use '<>' instead of '!='
>>> 1 <> 2
True

Leave a Comment