Skip to content

_dot_dict

Dotted dictionary for consistent interface.

Consider moving to Corallium, but I don’t have any uses for it yet.

Attributes⚓︎

DdictType module-attribute ⚓︎

DdictType = Union[Dict[str, Any], Box]

Return type from ddict().

Functions⚓︎

ddict ⚓︎

ddict(**kwargs)

Return a dotted dictionary that can also be accessed normally.

  • Currently uses python-box
  • Could consider cleverdict which had updates as recently as 2022
  • There are numerous other variations that haven’t been updated since 2020, such as munch, bunch, ddict
PARAMETER DESCRIPTION
**kwargs

keyword arguments formatted into dictionary

TYPE: Dict[str, Any] DEFAULT: {}

RETURNS DESCRIPTION
DdictType

dotted dictionary

TYPE: DdictType

Source code in calcipy/dot_dict/_dot_dict.py
@beartype
def ddict(**kwargs: Dict[str, Any]) -> DdictType:
    """Return a dotted dictionary that can also be accessed normally.

    - Currently uses `python-box`
    - Could consider `cleverdict` which had updates as recently as 2022
    - There are numerous other variations that haven't been updated since 2020, such as `munch`, `bunch`, `ddict`

    Args:
        **kwargs: keyword arguments formatted into dictionary

    Returns:
        DdictType: dotted dictionary

    """
    return Box(kwargs)