Skip to main content

DDD Value Objects implementation

Project description

Info:

DDD Value Object implementation.

Author:

Paweł Zadrożny @pawelzny <pawel.zny@gmail.com>

CI Status Documentation Status PyPI Repository Status Release Status Project Status Supported python versions Supported interpreters License

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)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page