Dict Helpers

basic_utils.dict_helpers.get_keys(d, keys, default=None)[source]

Returns multiple values for keys in a dictionary

Empty key values will be None by default

>>> d = {'x': 24, 'y': 25}
>>> get_keys(d, ('x', 'y', 'z'))
(24, 25, None)
Return type:Tuple
basic_utils.dict_helpers.get_in_dict(d, keys)[source]

Retrieve nested key from dictionary

>>> d = {'a': {'b': {'c': 3}}}
>>> get_in_dict(d, ('a', 'b', 'c'))
3
Return type:Any
basic_utils.dict_helpers.set_in_dict(d, keys, value)[source]

Sets a value inside a nested dictionary

>>> d = {'a': {'b': {'c': 3}}}
>>> set_in_dict(d, ('a', 'b', 'c'), 10)
>>> d
{'a': {'b': {'c': 10}}}
Return type:None
basic_utils.dict_helpers.prune_dict(d)[source]

Returns new dictionary with falesly values removed.

>>> prune_dict({'a': [], 'b': 2, 'c': False})
{'b': 2}
Return type:dict