filter_types

filter_types

filter_types(t, seq, min_el=0, max_el=None)[source]

Searches for elements of a given type in a sequence

Parameters
  • t (Type[TypeVar(_Class)]) – Type to search for

  • seq (Sequence[Any]) – Sequence to search in

  • min_el (int) – Minimum number of elements to recover

  • max_el (Optional[int]) – Maximum number of elements to recover (optional)

Raises

ValueError – if the number of recovered elements is not between min_el and max_el

Return type

Sequence[TypeVar(_Class)]

Returns

A sequence of elements of the given type