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
>>> audeer.flatten_list([1, 2, 3, [4], [], [[[[[[[[[5]]]]]]]]]]) [1, 2, 3, 4, 5] >>> audeer.flatten_list([[1, 2], 3]) [1, 2, 3]