Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.