WrightTools.kit.flatten_list

WrightTools.kit.flatten_list(items, seqtypes=(<class 'list'>, <class 'tuple'>), in_place=True)[source]

Flatten an irregular sequence.

Works generally but may be slower than it could be if you can make assumptions about your list.

Source

Parameters
  • items (iterable) – The irregular sequence to flatten.

  • seqtypes (iterable of types (optional)) – Types to flatten. Default is (list, tuple).

  • in_place (boolean (optional)) – Toggle in_place flattening. Default is True.

Returns

Flattened list.

Return type

list

Examples

>>> l = [[[1, 2, 3], [4, 5]], 6]
>>> wt.kit.flatten_list(l)
[1, 2, 3, 4, 5, 6]