reverse_recursive

emlib.misc.reverse_recursive(seq)[source]

Reverse seq recursively

Parameters:

seq (list) – a (possibly nested) list of elements

Returns:

a reversed version of seq where all sub-lists are also reversed.

>>> reverse_recursive([1, 2, [3, 4], [5, [6, 7]]])
[[[7, 6], 5], [4, 3], 2, 1]

NB: only lists will be reversed, other iterable collection remain untouched