A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2005-September/340334.html below:

is there a better way to check an array?

is there a better way to check an array? 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

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4