Skip to content

dict

deepget(data, key, default=None)

It takes a dictionary, a list of keys, and a default value, and returns the value of the key in the dictionary, or the default value if the key is not found

:param data: The data to search through :param key: The key to search for :param default: The default value to return if the key is not found :return: The value of the key in the data.

Source code in backend/shared/dict.py
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
def deepget(data, key, default=None):
    """
    It takes a dictionary, a list of keys, and a default value, and returns the value of the key in the dictionary, or the
    default value if the key is not found

    :param data: The data to search through
    :param key: The key to search for
    :param default: The default value to return if the key is not found
    :return: The value of the key in the data.
    """
    try:
        return reduce(getitem, key, data)
    except (KeyError, IndexError):
        return default