flattened

emlib.iterlib.flattened(s, exclude=(<class 'str'>, ), levels=None, out=None)[source]

Like flatten, but returns a list instead of an iterator

Parameters:
  • s (Iterable[Union[TypeVar(T), Iterable[TypeVar(T)]]]) – the seq to flatten.

  • exclude – types to exclude

  • levels (Optional[int]) – how many levels to flatten (None: flatten all levels)

  • out (Optional[list]) – if given, the flattened result is appended to this list

Return type:

list[TypeVar(T)]

Returns:

a list with the elements in s flattened