nip.utils.data.nested_dict_keys_stringified

nip.utils.data.nested_dict_keys_stringified#

nip.utils.data.nested_dict_keys_stringified(data: dict, separator='.') list[str][source]#

Get the keys of a nested dict as a list of joined strings.

A nested dict is a dict that may contain other dicts as values. This function recursively traverses the dict to get all the keys and joins them with a separator.

Parameters:
  • data (dict) – The nested dict to get the keys of.

  • separator (str) – The separator to use between keys.

Returns:

keys (list) – The keys of the nested dict.

Examples

>>> data = {"a": {"b": 1, "c": 2}, "d": 3}
>>> get_nested_dict_keys(data)
["a.b", "a.c", "d"]