[Python-bugs-list] [ python-Bugs-497005 ] __cmp__ method returns unexpected result
noreply@sourceforge.net
noreply@sourceforge.net
Thu, 27 Dec 2001 02:02:50 -0800
Bugs item #497005, was opened at 2001-12-27 02:02
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=497005&group_id=5470
Category: Type/class unification
Group: Python 2.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Matthew Russell (mattsurf76)
Assigned to: Nobody/Anonymous (nobody)
Summary: __cmp__ method returns unexpected result
Initial Comment:
There seems to be a problem overriding the __cmp__
metaclass method in the new release :
class A :
def __init__(self, x, y)
self.x=x
self.y=y
def __cmp__(self, other) :
return (self.x==other.x and self.y==other.y)
a=A(1,2)
aa=A(1,2)
Where :
a==aa is false
and cmp(a,aa) is true?
this is also the behaviour if the __cmp__ method is
*not* overriden, i.e
class Test :
def __init__(self, *args) :
self.args = args
aTest = Test(1)
aTest1 = Test(1)
aTest==aTest1 (returns 0)
cmp(aTest, aTest1) (returns 1)
Is this intended?
Python 2.2 (#28, Dec 21 2001, 12:21:22) [MSC 32 bit
(Intel)] on win32
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=497005&group_id=5470