find_by_key

Contents

find_by_key#

find_by_key(data: dict, target: str) Any[source]#

Find a value by key in a dictionary.

Parameters:
  • data (dict) – Dict to walk through

  • target (str) – target key

Returns:

Value data[…][target]

Return type:

Any

Example

>>> dct = {
>>>         "A": "T",
>>>         "R": 3,
>>>         "B": {
>>>             "C": {
>>>                 "D": "value"
>>>                  }
>>>              }
>>>        }
>>> find_by_key(dct, "D")
"value"