This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients
Date 2003-03-09.19:16:17
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
Logged In: YES 
user_id=593130

The documented behavior of list.index(o) is, and I suspect  
always has been (at least the first part)
"s.index(x) return smallest i such that s[i] == x" 
"Raises ValueError when x is not found in s."

If the matching were on identity, [some-literal].index(some-
literal) would raise ValueError instead of returning 0 if 
some-literal were not interned or recorded in some way so 
that both references were to the same object.  Making
.index() dependent on the (changing) details of object 
implementation and interning would make it both 
surprising, version-dependent, and pretty useless.

Since .list() was added 12 years ago, there have been two 
changes recorded in the CVS log: 1) flag multiple args as 
an error and 2) switch from list_compare() to the newer 
list_richcompare() (2 years ago)..  This latter perhaps 
fixed a previous bug.

When you write a .__eq__(s,o) method returning True, you 
are saying that you *want* the interpreter to see s==0 as 
True!  So either don't do that, or write an 'iddex' function 
that does what you want.

History
Date User Action Args
2007-08-23 14:11:42adminlinkissue698561 messages
2007-08-23 14:11:42admincreate