DDD Value Objects implementation
Project description
- Info:
DDD Value Object implementation.
Features
Value object can’t be changed once created
Two objects with the same values are considered equal
Access to values after dot: value.my_value
Access to values like dict: value[‘my_value’]
Installation
pip install vo
Package: https://pypi.org/project/vo/
Documentation
Read full documentation on: http://vo.readthedocs.io
Quick Example
>>> from vo import Value
...
>>> class Book(Value):
... price = None
... title = None
... publisher = None
...
>>> book = Book(price=120, title='Python for masses', publisher='SPAM')
>>> book
Book(price=120, title='Python for masses', publisher='SPAM')
>>> book.title
'Python for masses'
>>> book['price']
120
>>> book.price = 230
Traceback (most recent call last):
File "<input>", line 1, in <module>
raise ImmutableInstanceError
vo.value.ImmutableInstanceError: Modification of Value instance is forbidden.
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
vo-0.3.1.tar.gz
(25.2 kB
view hashes)