Differences of "!=" operator behavior in python3 and python2 [ bug? ]
Ian Kelly
ian.g.kelly at gmail.com
Sun May 12 19:40:17 EDT 2013
On Sun, May 12, 2013 at 5:23 PM, Mr. Joe <titanix88 at gmail.com> wrote:
> I seem to stumble upon a situation where "!=" operator misbehaves in
> python2.x. Not sure if it's my misunderstanding or a bug in python
> implementation. Here's a demo code to reproduce the behavior -
The != operator is implemented by the __ne__ special method. In
Python 3, the default implementation of __ne__ is to call __eq__ and
return the opposite of whatever it returns. In Python 2, __ne__ calls
the older __cmp__ method instead, which is no longer meaningful in
Python 3.
More information about the Python-list
mailing list