Differences of "!=" operator behavior in python3 and python2 [ bug? ]
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Tue May 14 01:09:48 EDT 2013
On Mon, 13 May 2013 19:22:24 -0400, Dave Angel wrote:
> So which special methods should the <> operator call? By rights it
> ought to call both __gt__ and __lt__ and return True if either of them
> is True.
The <> operator comes from Pascal, where it was used as "not equal" since
ASCII doesn't include the ≠ operator. Algol 60, by contrast, used ≠ since
it was invented before ASCII.
The use of ! as "not" is a C-ism and isn't universal.
Given the data types Pascal had as standard back when it was invented, I
think it is fair to say that "less than, or greater than" was logically
equivalent to "not equal to". That's no longer the case though.
Interestingly, later versions of Apple's "Standard Apple Numeric
Environment" (SANE) included separate relational operations for "less
than or greater than" and "not equal to". So if x was a NAN, then you
could have pseudo-code like this:
x != y # true
x <> y # false
--
Steven
More information about the Python-list
mailing list