[New-bugs-announce] [issue29511] Add 'find' as build-in method for lists

George Shuklin report at bugs.python.org
Thu Feb 9 04:17:00 EST 2017


New submission from George Shuklin:

I found that Python provides 'find()' and 'in' methods for strings, but lacking same functionality for lists.

Because strings and lists are very similar, it's reasonable to expect same function available for both.

Here long and rather ugly hack list on stackoverflow about 'reinventing the wheel': http://stackoverflow.com/questions/16579085/python-verifying-if-one-list-is-a-subset-of-the-other

There are short few proposals, each of them imperfect:
1. Use sets intersection. This looses count and order
2. Use collections.Count. This looses order
3. all(x in two for x in one) - looses order

Propsal: adds a normal 'find' method which will behave the same way as find for strings. It should perform normal __cmp__ call on each element, or, may be, asking for optional lambda to perform comparison of elements.

----------
components: Interpreter Core
messages: 287394
nosy: george-shuklin
priority: normal
severity: normal
status: open
title: Add 'find' as build-in method for lists
type: enhancement
versions: Python 2.7, Python 3.3, Python 3.4, Python 3.5, Python 3.6, Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29511>
_______________________________________


More information about the New-bugs-announce mailing list