skoot.utils.flatten_all

skoot.utils.flatten_all(container)[source][source]

Recursively flattens an arbitrarily nested iterable.

Parameters:

container : array_like, shape=(n_items,)

The iterable to flatten. If the container is not iterable, it will be returned in a list as [container]

Returns:

res : generator

A generator of all of the flattened values.

Examples

The example below produces a list of mixed results:

>>> a = [[[], 3, 4],['1', 'a'],[[[1]]], 1, 2]
>>> list(flatten_all(a))
[3, 4, '1', 'a', 1, 1, 2]