recursive_get#
- recursive_get(dict_, key, default=None)[source]#
Recursively get a key from a nested dictionary.
The key is first looked for at the top level of
dict_, then in its nested dictionaries (depth first, in insertion order). The first non-None value found is returned.- Parameters:
- Returns:
object– The value of the key if found, otherwisedefault.
Examples
>>> recursive_get({"a": 1, "b": {"c": 2}}, "c") 2