Dictionaries¶
There are a few utility dictionaries available. All of them inherit from the
base dict class, and can be used as drop-ins for the standard dict
type. There are a few “primitive” base types that are then composed to
more complex types. To use these types, import kutils.dicts.
AttrDict: this dictionary provides access to the keys as attributes.NoneDict: this dictionary returnsNonefor non-existent keys. This means it will not throw aKeyErrorfor top-level keys; note that nested dictionaries may not be `NoneDict`s.StrDict: this dictionary returns an empty string for non-existent keys.DictDict: this dictionary returns an emptyStrDictfor non-existent keys. This is mostly useful for values that are nested dictionaries of keys.AttrNoneDict: this is a composition of theAttrDictand theNoneDict: it provides access to its keys as attributes, and returnsNonefor missing keys or attributes; this means missing top-level keys and attributes will not throwKeyErrororAttributeError.AttrDictDict: this is a composition of theAttrDictandDictDict: it provides access to its keys as attributes, and returns an emptyStrDictfor missing keys or attributes; this means missing top-level keys and attributes will not throwKeyErrororAttributeError.