is there a better way to check an array?
Peter Hansen
peter at engcorp.com
Fri Sep 2 11:15:11 EDT 2005
Mike Meyer wrote:
> "Steve M" <sjmaster at gmail.com> writes:
>>my_list.find(candidate)
>>-returns the index into my_list of the first occurrence of candidate.
>>Returns -1 if candidate doesn't occur in my_list.
>
> Lists don't have a find method. strings do. Why is a good question.
Probably because at one point lists didn't even have the index() method,
and when it was suggested and (I believe) Raymond H. added it, I suspect
nobody also suggested that implementing find() was a good idea so it
wasn't done.
And, given both that index() exists and the recent discussion about the
potential problems caused by find() returning a valid slice index when
it fails, maybe it's _not_ a good idea...
-Peter
More information about the Python-list
mailing list