Say I have this nested dict:
[
{
"id": 1,
"name": "Mammals",
"animals": [
{
"id": 1,
"name": "Chinchilla",
"extinct": False
},
{
"id": 2,
"name": "Wooly Mammoth",
"extinct": True
},
...
]
},
...
]
But Oh No! The Chinchilla has gone extinct! Now I have another, smaller, dict of identical format which represents updates to the extinct
value on one or more members:
[
{
"id": 1,
"name": "Mammals",
"animals": [
{
"id": 1,
"name": "Chinchilla",
"extinct": True
},
...
]
},
...
]
I could start nesting for
loops, throw in an if
or two to compare id
values, and tackle this pretty easily - but that many layers of nesting just feels bad to do. Is there a better and/or more pythonic way to do this?