Message14995
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.
|
|
Date |
User |
Action |
Args |
2007-08-23 14:11:42 | admin | link | issue698561 messages |
2007-08-23 14:11:42 | admin | create | |
|