I am creating dict in python and this dict may includes lists and sub dicts . If I want to check a key exist in any dict first I have reach to that dict and then only I can check wether the key exists or not . But is there any way that I can check key existence using parent dict only means if parent dict have any child dicts then searching goes to every level and let me know that wether the key exist in entire dict or not and then using that key I can insert or delete elments in that dict which includes that key.
e.g., I have this
[
{
'groupName': u'MainMenu_1',
'menuItems': [
{
'action': u'/home\r\n',
'sub_1': [
],
'id': 1L,
'name': u'Home\r\n'
},
{
'action': u'/inventory',
'sub_2': [
],
'id': 2L,
'name': u'Inventory\r\n'
},
{
'action': u'/accounting\r\n',
'sub_3': [
{
'action': u'/gl\r\n',
'name': u'GL\r\n',
'sub_4': [
]
},
{
'action': u'/ap\r\n',
'name': u'AP\r\n',
'sub_5': [
]
},
{
'action': u'/ar\r\n',
'sub_6': [
],
'name': u'AR\r\n'
}
],
'id': 3L,
'name': u'Accounting\r\n'
},
{
'action': u'/crm\r\n',
'sub_8': [
],
'id': 8L,
'name': u'CRM\r\n'
}
]
},
{
'groupName': u'MainMenu_2',
'menuItems': [
{
'action': u'/iv-receive\r\n',
'sub_9': [
],
'id': 9L,
'name': u'Receiving\r\n'
},
{
'action': u'/iv-shipping\r\n',
'sub_10': [
],
'id': 10L,
'name': u'Shipping\r\n'
}
]
}
]
Now if in above example I want to search for any key like sub_1 , sub_3, sub_6 then how I can search for this key