dolor.util.attr_dict¶
Contains AttrDict
- class AttrDict(name_or_elems=None, **kwargs)[source]¶
Bases:
collections.abc.MutableMappingA wrapper around
dictthat also lets you access keys as attributes.- Parameters
name_or_elems (
strordict, optional) –If a
str, then it will generate a new type with that name that inherits fromAttrDict.If a
dict, then it will use it as its underlying dictionary.If unspecified, then the initial underlying dictionary will be empty.
**kwargs – Will be used with
dict.update()to update the underlying dictionary.
Examples
>>> import dolor >>> MyAttrDict = dolor.util.AttrDict("MyAttrDict") >>> MyAttrDict.__name__ 'MyAttrDict' >>> x = MyAttrDict(y=0) >>> x.y 0 >>> x["y"] 0