Skip to content

Instantly share code, notes, and snippets.

@lunaluxie
Created September 23, 2017 15:23
Show Gist options
  • Save lunaluxie/9507ca63e308518b6675c3901e069932 to your computer and use it in GitHub Desktop.
Save lunaluxie/9507ca63e308518b6675c3901e069932 to your computer and use it in GitHub Desktop.
def flatten(obj):
flat = []
if hasattr(obj, '__iter__'):
for i in obj:
flat.extend(flatten(i))
else:
flat.append(obj)
return flat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment