Skip to content

Instantly share code, notes, and snippets.

@zabbarob
Created September 7, 2013 19:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zabbarob/6478583 to your computer and use it in GitHub Desktop.
Save zabbarob/6478583 to your computer and use it in GitHub Desktop.
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