dict module¶
- class toolbox.dict.DotDict¶
Bases:
dictA dictionary that supports attribute-style access (dot notation).
- Example:
d = DotDict(a=1) print(d.a) # 1
- toolbox.dict.flatten_dict(d: Dict[Any, Any], parent_key: str = '', sep: str = '.') Dict[str, Any]¶
Flatten a nested dictionary, joining keys with a separator.
- Args:
d (Dict[Any, Any]): The dictionary to flatten. parent_key (str, optional): The base key for recursion. Defaults to ‘’. sep (str, optional): Separator between keys. Defaults to ‘.’.
- Returns:
Dict[str, Any]: A flat dictionary with joined key paths.
- toolbox.dict.merge_dicts(dict1: Dict[Any, Any], dict2: Dict[Any, Any]) Dict[Any, Any]¶
Recursively merge two dictionaries.
- Args:
dict1 (Dict[Any, Any]): The base dictionary. dict2 (Dict[Any, Any]): The dictionary to merge into the base.
- Returns:
Dict[Any, Any]: The merged dictionary.