REPOST: cmp

Matt Russell mattsurf76 at hotmail.com
Thu Dec 27 09:06:03 EST 2001


Well, I just made myself look silly. I admit it...

when I type 1==1 into the interpreter, I thought if it was true, the
result is 1 -  this is right. But cmp(1,1) actually returns 0 (in
accordance to the docs)

But why then are we given the mechanism to compare instances of
classes via the __cmp__ def ?

Collegues of mine have used this to return 1 (truth) if two instances
are equal (instanceA==instanceB).... this obviously wasn't the
intended purpose. (__cmp__ shuold return 0 if the result of cmp(a,b)
is to be trusted??

Perhaps then could someone explain to me how one compares classes
useing the == operator, or indeed if this bad programming practice.

I hope I didn't waste too much of guido's time when I posted a bug on
sourceforge :(

========= WAS CANCELLED BY =======:
Path: news.sol.net!spool0-milwwi.newsops.execpc.com!newsfeeds.sol.net!news-out.visi.com!hermes.visi.com!wesley.videotron.net!newsfeed.direct.ca!look.ca!newsfeed.dacom.co.kr!feeder.kornet.net!news1.kornet.net!ua4canc3ll3r
From: mattsurf76 at hotmail.com (Matt Russell)
Newsgroups: comp.lang.python
Subject: cmsg cancel <f8c2d3e0.0112270606.adf923e at posting.google.com>
Control: cancel <f8c2d3e0.0112270606.adf923e at posting.google.com>
Date: Mon, 31 Dec 2001 02:13:32 GMT
Organization: A poorly-installed InterNetNews site
Lines: 2
Message-ID: <cancel.f8c2d3e0.0112270606.adf923e at posting.google.com>
NNTP-Posting-Host: 211.57.49.2
X-Trace: news2.kornet.net 1009775762 27193 211.57.49.2 (31 Dec 2001 05:16:02 GMT)
X-Complaints-To: usenet at news2.kornet.net
NNTP-Posting-Date: Mon, 31 Dec 2001 05:16:02 +0000 (UTC)
X-No-Archive: yes
X-Unac4ncel: yes
X-Commentary: I love NewsAgent 1.10 and the Sandblaster Cancel Engine Build 74 (19 March 1999)
This message was cancelled from within Mozilla.



More information about the Python-list mailing list