I have a nested python dictionary
data structure. I want to read its keys and values without
using collection
module. The data structu
You could use benedict
(a dict
subclass) and the traverse utility method:
Installation: pip install python-benedict
from benedict import benedict
d = benedict({'dict1': {'foo': 1, 'bar': 2}, 'dict2': {'baz': 3, 'quux': 4}})
def traverse_item(dct, key, value):
print('key: {} - value: {}'.format(key, value))
d.traverse(traverse_item)
Documentation: https://github.com/fabiocaccamo/python-benedict
Note: I am the author of this project.