Created
April 20, 2012 11:39
-
-
Save ferdef/2427956 to your computer and use it in GitHub Desktop.
Flatten keys from a nested dictionary
This file contains 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 flat_keys(dictionary, out): | |
""" | |
Flatten keys from a nested dictionary | |
out should be an empty list | |
""" | |
for key in dictionary.keys(): | |
out.append(key) | |
if isinstance(dictionary[key], dict): | |
flat_keys(dictionary[key], out) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment