skbio.util.flatten

skbio.util.flatten(items)[source]

Removes one level of nesting from items

Parameters:

items : iterable

list of items to flatten one level

Returns:

flattened_items : list

list of flattened items, items can be any sequence, but flatten always returns a list.

Examples

>>> from skbio.util import flatten
>>> h = [['a', 'b', 'c', 'd'], [1, 2, 3, 4, 5], ['x', 'y'], ['foo']]
>>> print(flatten(h))
['a', 'b', 'c', 'd', 1, 2, 3, 4, 5, 'x', 'y', 'foo']