[Python-ideas] list.index() extension

Greg Ewing greg.ewing at canterbury.ac.nz
Sun Apr 5 01:36:51 CEST 2009


Christian Heimes wrote:

>>def index(self, obj, predicate=operator.eq):
>>    for idx, item in enumerate(self):
>>        if predicate(item, obj):
>>            return idx
>>    raise IndexError

This looks more like it belongs in the itertools module,
if there isn't something there already that does it.

-- 
Greg



More information about the Python-ideas mailing list