Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
def flatten(l):
for el in l:
if isinstance(el, collections.Iterable) and not isinstance(el, basestring):
for sub in flatten(el):
yield sub
else:
yield el
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment