libb.unnest

unnest(d, keys=None)[source]

Recursively convert dict into list of tuples.

Parameters:
  • d (dict) – Dictionary to unnest.

  • keys (list) – Internal key accumulator (do not set manually).

Returns:

List of tuples representing paths to leaf values.

Return type:

list

Example:

>>> unnest({'a': {'b': 1}, 'c': 2})
[('a', 'b', 1), ('c', 2)]