kwave.utils.dotdictionary module

class dotdict[source]

Bases: dict

A dictionary supporting dot notation.

This class extends the built-in dict type by adding support for accessing items using dot notation (e.g. dotdict.a.b.c) instead of square bracket notation (e.g. dotdict[‘a’][‘b’][‘c’]). The class also provides a lookup method for looking up a value in a nested dictionary structure using a dot-separated path (e.g. “a.b.c”).

Examples

>>> d = dotdict({'a': {'b': {'c': 1}}})
>>> d.a.b.c
1
>>> d.lookup('a.b.c')
1
__init__(*args, **kwargs)[source]
Parameters:
  • args (Any)

  • kwargs (Any)

Return type:

None

lookup(dotkey)[source]

Look up a value in a nested dictionary structure using a dot-separated path.

Parameters:

dotkey (str) – A dot-separated path to the value, e.g. “a.b.c”.

Returns:

The value at the specified path.

Raises:

KeyError – If the specified path does not exist in the dictionary.

Return type:

Any