I have looked but not found what I am looking for -- which is a Pythonic way of retrieving different parts of the tree knowing something at the lower levels.
I'm pretty sure it is because I am not asking the question correctly.
I have dictionary. The dictionary contains many things, among them a list of dictionaries. Those dictionaries have data, among them a list of dictionaries.
aa = {"ab": 23, # aa is a dictionary
"ac": "example",
"ad": [{"ad_a": 37, # ad is a list of dictionaries
"ad_b": "some text",
"ad_c": [{"ad_c_a": 49, # ad_c is a list of dictionaries
"ad_c_b": "some other text",
"the key": "THE IMPORTANT THING",
"ad_c_d": "more stuff"
},
{"bd_c_a": 49,
"bd_c_b": "some other text",
"bd_c_c": "some other text",
"bd_c_d": "more stuff"
}
{another dictionary},
]
},
{another dictionary},
{another dictionary}]
}
Currently, I loop through the various levels dictionaries until I find THE IMPORTANT THING is in aa["ad"]["ad_c"]
That tell me which list element of ad_c I am in. Knowing that, what is the Pythonic way to retrieve the values from aa["ad"]["ad_c"]["ad_c_a"] and other items in the list element?
I don't know where I'll end up in ad until I've done the looping, but after THE IMPORTANT THING is found, I do.
Just writing this down has given me some ideas on what to try, but I'll post it anyway in case I don't find the answer right away.
-Craig