AttribDictable¶
-
class
privex.helpers.extras.attrs.
AttribDictable
[source]¶ A small mixin class for
attr.s()
classes, allowing them to behave like dictionaries, and support casting into dictionaries usingdict(x)
.Usage:
>>> import attr >>> from privex.helpers import AttribDictable >>> >>> @attr.s >>> class Example(AttribDictable): ... hello = attr.ib(type=str) ... testing = attr.ib(type=bool, default=True) ... >>> x = Example(hello='world') >>> x['hello'] 'world' >>> x['hello'] = 'lorem ipsum' >>> dict(x) {'hello': 'lorem ipsum', 'testing': True}
-
__init__
() → None Method generated by attrs for class AttribDictable.
-