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 - """ # -*- coding: utf-8 -*- from __future__ import unicode_literals, print_function
class DemoClass(object): def __init__(self, val): self.val = val def __eq__(self, other): return self.val == other.val x = DemoClass('a') y = DemoClass('a') print("x == y: {0}".format(x == y)) print("x != y: {0}".format(x != y)) print("not x == y: {0}".format(not x == y)) """ In python3, the output is as expected: """ x == y: True x != y: False not x == y: False """ In python2.7.3, the output is: """ x == y: True x != y: True not x == y: False """ Which is not correct!! Thanks in advance for clarifications. Regards, TB -- http://mail.python.org/mailman/listinfo/python-list