Why prefer != over <> for Python 3.0?

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Sun Mar 30 12:35:30 CEST 2008


On Sun, 30 Mar 2008 01:13:04 -0700, dewitters wrote:

> On Mar 29, 6:34 pm, Lie <Lie.1... at gmail.com> wrote:
>> You're forcing your argument too much, both != and <> are NOT standard
>> mathematics operators -- the standard not-equal operator is >< -- and I
>> can assure you that both != and <> won't be comprehensible to non-
>> programmers.
> 
> What I meant was that both < and > are standard mathematics operators,
> and that by that knowledge one could deduce what <> means.

But you would be wrong, because "less than or greater than" is not the 
same as "not equal to".


>>> 3+2j != 2-3j
True
>>> (3+2j < 2-3j) or (3+2j > 2-3j)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: no ordering relation is defined for complex numbers


-- 
Steven



More information about the Python-list mailing list