[Python-ideas] list.index() extension

Christian Heimes lists at cheimes.de
Sun Apr 5 00:45:57 CEST 2009


Benjamin Peterson schrieb:
> I would like to propose a extra parameter `predicate` to list.index() like this:
> 
> def index(self, obj, predicate=operator.eq):
>     for idx, item in enumerate(self):
>         if predicate(item, obj):
>             return idx
>     raise IndexError

+0 from me

Are you planing in adding the same feature for count, too?

Christian




More information about the Python-ideas mailing list