kd.kontext.get_by_path#
- kauldron.kontext.get_by_path(
- obj: Any,
- path: str | tuple[str, ...] | kauldron.kontext.paths.Path,
- default=Ellipsis,
Get (nested) item or attribute by given path.
- Parameters:
obj – The object / dict / dataclass to retrieve the value from.
path – The path to retrieve, either as a string “foo[1]”, a tuple (“foo”, 1) or a Path object.
default – return value if no value is found. By default, raise an error.
- Returns:
The value corresponding to the path if it exists, or default otherwise.
- Raises:
TypeError – if the path is not str, tuple or
Path.