Not Logged In

dict_digger 0.2.1

Useful syntax for digging into nested dictionaries, lists and tuples, and removes the need to check if a key exists

Digs into Dicts

Useful syntax for digging into nested dictionaries, lists and tuples, and removes the need to check if a key or index exists, or handling of
KeyError or IndexError

Installation

$ pip install dict_digger

Usage

importdict_diggerh={'a':{'b':'tuna','c':'fish'},'b':{}}result=dict_digger.dig(h,'a','b')printresult# prints 'tuna'result=dict_digger.dig(h,'c','a')printresult# prints None# Important!! Does not through an error, just returns None#but if you likeresult=dict_digger.dig(h,'c','a',fail=True)# raises a KeyError# also support complex objects so ...complex={'a':{['tuna','fish']},'b':{}}result=dict_digger.dig(complex,'a',0)printresult#prints tuna