flatten_list()¶
- audeer.flatten_list(nested_list)[source]¶
Flatten an arbitrarily nested list.
Implemented without recursion to avoid stack overflows. Returns a new list, the original list is unchanged.
Examples
>>> flatten_list([1, 2, 3, [4], [], [[[[[[[[[5]]]]]]]]]]) [1, 2, 3, 4, 5] >>> flatten_list([[1, 2], 3]) [1, 2, 3]