ValueObject is a dict-like object that exposes keys as attributes.
Project description
ValueObject
License: ISC - See LICENSE file
ValueObject
is a dict
-like object that exposes keys as attributes.
You can use it like a regular dictionary (in fact, it is a subclass
and does not override its __init__
). You can use attribute or item
access to get or set values.
>>> from valueobject import ValueObject
>>> vo = ValueObject(key=1)
>>> vo['key']
1
>>> vo.key
1
>>> vo['key'] += 1
>>> vo.key += 1
>>> vo['key']
3
>>> vo.key
3
Usability notes:
- If you need to access a key that is not a valid Python identifier (for example, it includes spaces), use regular dict access.
- All regular
object
,dict
andValueObject
methods will be returned on attribute access. A key such ascopy
needs to be accessed via item access syntax (e.g.valueobject['copy']
).
Changelog
- 1.0.3: Minor build fixes, to make the setup.py file python3 safe. While the rest of the library was python3 safe all along, that file was not… 😬
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
valueobject-1.0.3.tar.gz
(3.4 kB
view hashes)
Built Distribution
Close
Hashes for valueobject-1.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1ec4a925e24afc6850008ef13d953c8dbf0595b6962e597657e98152aff8bc6 |
|
MD5 | 867fdc63aa646691da33e435c2e9207b |
|
BLAKE2b-256 | 1a673db084eaf286b3f7e2d3b34872aad305c72b987ffa18cb1a03e431855d2d |