Skip to content

Instantly share code, notes, and snippets.

@dnmellen
Last active December 29, 2015 04:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dnmellen/7618531 to your computer and use it in GitHub Desktop.
Save dnmellen/7618531 to your computer and use it in GitHub Desktop.
My try for "flatten" with yield from
from collections import Iterable
def flatten(iterable):
for item in iterable:
if isinstance(item, Iterable):
yield from flatten(item)
else:
yield item
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment