Created
September 23, 2017 15:23
-
-
Save lunaluxie/9507ca63e308518b6675c3901e069932 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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