On Sat, May 23, 2020, 10:54 AM Rob Cliffe via Python-ideas

> index_of(needle, haystack, key=func)
>
> Sounds like a list comprehension: [ needle for needle in haystack if
> func(needle) ]
>

The times it doesn't sound like a list comprehension is when you have a
million items in the list, 100k of which match the predicate, but you only
care about the first one... Or even just the first ten.

Still, generator comprehension are great. And next() is an excellent
function.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/2ZQR3HMRLIPSOAAK7GJQBJX6MQLUEIKD/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to