Created
December 8, 2016 16:55
-
-
Save ben181231/6c8aa783bd320c2c15f7daa8f3b0e699 to your computer and use it in GitHub Desktop.
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
# Ref. https://gist.github.com/href/1319371 | |
from collections import namedtuple | |
def convert(dictionary): | |
for key, value in dictionary.items(): | |
if isinstance(value, dict): | |
dictionary[key] = convert(value) | |
if isinstance(value, list): | |
dictionary[key] = [convert(i) for i in value] | |
return namedtuple('GenericDict', dictionary.keys())(**dictionary) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment