A RetroSearch Logo

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

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2001-July/016263.html below:

[Python-Dev] find method for lists

[Python-Dev] find method for lists [Python-Dev] find method for listsGuido van Rossum guido@digicool.com
Wed, 25 Jul 2001 12:37:09 -0400
> This has probably been discussed before, but why doesn't the list object
> support a find method?  Seems like if a non-exception-raising index method
> is good enough for strings, it should be good enough for lists as well.  I
> realize I can use "l.count(x) and l.index(x)" to avoid the possible
> ValueError.  (Or maybe it's strings that shouldn't have find, but can't be
> deleted not for code breakage reasons?)
> 
> I'm mostly just curious.  Am I missing something?

List searching is much less common, and the string functions (both
index() and find()) have different semantics: they look for
substrings, while list.index() only searches for a particular item.

With lists, if you need this, you're probbly using the wrong
datastructure.  With strings, substring matching is a standard
pattern.

--Guido van Rossum (home page: http://www.python.org/~guido/)



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