earthkit.data.utils.dotdict¶
Classes¶
A dictionary that allows access to its keys as attributes. |
Module Contents¶
- class earthkit.data.utils.dotdict.DotDict(*args, **kwargs)¶
Bases:
dictA dictionary that allows access to its keys as attributes.
>>> d = DotDict({"a": 1, "b": {"c": 2}}) >>> d.a 1 >>> d.b.c 2 >>> d.b = 3 >>> d.b 3
The class is recursive, so nested dictionaries are also DotDicts.
The DotDict class has the same constructor as the dict class.
>>> d = DotDict(a=1, b=2)
- classmethod from_file(path)¶
Create a DotDict from a file.
- Parameters:
path (
str) – The path to the file.- Returns:
The created DotDict.
- Return type:
- classmethod from_json_file(path)¶
Create a DotDict from a JSON file.
- Parameters:
path (
str) – The path to the JSON file.- Returns:
The created DotDict.
- Return type:
- classmethod from_toml_file(path)¶
Create a DotDict from a TOML file.
- Parameters:
path (
str) – The path to the TOML file.- Returns:
The created DotDict.
- Return type: