1>>> from collections import Iterable
2>>> def flat(lst):
3... for parent in lst:
4... if not isinstance(i, Iterable):
5... yield parent
6... else:
7... for child in flat(parent):
8... yield child
9...
10>>> list(flat(([1,[2,2,2],4]))
11[1, 2, 2, 2, 4]