get_recursive

  • full name: tenpy.tools.misc.get_recursive

  • parent module: tenpy.tools.misc

  • type: function

tenpy.tools.misc.get_recursive(nested_data, recursive_key, separator='.', default=<object object>)[source]

Extract specific value from a nested data structure.

Parameters:
  • nested_data (dict of dict (-like)) – Some nested data structure supporting a dict-like interface.

  • recursive_key (str) – The key(-parts) to be extracted, separated by separator. A leading separator is ignored.

  • separator (str) – Separator for splitting recursive_key into subkeys.

  • default – If not specified, the function raises a KeyError if the recursive_key is invalid. If given, return this value when any of the nested dicts does not contain the subkey.

Returns:

For example, recursive_key="some.sub.key" will result in extracting nested_data["some"]["sub"]["key"].

Return type:

entry

See also

set_recursive

same for changing/setting a value.

flatten

Get a completely flat structure.