O'Reilly logo
  • Vlad Bezden thinks this is interesting:

predicate: Callable

From

Cover of Functional Python Programming - Second Edition

Note

from typing import Callable, Iterable, Any

def first(predicate: Callable, collection: Iterable) -> Any: return next((x for x in collection if predicate(x)), None)