nip.utils.data.nested_dict_keys#
- nip.utils.data.nested_dict_keys(data: dict) list[tuple[str, ...]] [source]#
Get the keys of a nested dict as a list of tuples of 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, where each key is a tuple of strings.
- Parameters:
data (dict) – The nested dict to get the keys of.
- 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",)]