epy.splitby

epy.splitby#

etils.epy.splitby(
iterable: Iterable[etils.epy.itertools._T],
predicate: Callable[[etils.epy.itertools._T], bool],
) tuple[list[etils.epy.itertools._T], list[etils.epy.itertools._T]][source]

Split the iterable into 2 lists (false, true), based on the predicate.

Example:

small, big = epy.splitby([100, 4, 4, 1, 200], lambda x: x > 10)
assert small == [4, 4, 1]
assert big == [100, 200]
Parameters:
  • iterable – The iterable to split

  • predicate – Function applied to split

Returns:

False list, True list