Value Objects in Python
(GitHub has a rendered version of this readme: https://github.com/stevewedig/value-objects-in-python/)
This library makes it easy to implement value objects in Python. The library's rationale and usage instructions can be found in this blog post: Value Objects in Java & Python.
- GitHub Repo: https://github.com/stevewedig/value-objects-in-python
- License: This project is in the public domain via Unlicense.
Vladimir Keleshev has an alternative Python library for value objects that makes some different design decisions. My library is a combination of techniques I've used before and Vladimir's technique of using
__init__ to indicate field name, order, and default values.
Installation via Pip
The easiest way to install this library is to use Pip:
pip install value_objects
Installation via copying files
Alternatively you can just copy the library code directory into your own codebase.
Running Tox tests in Vagrant
Vagrant (with VirtualBox is a great way to run sandboxed experiments on your dev machine. I use Vagrant plus Tox to run this library's tests in Python 2.x and 3.x without affecting my dev machine. The three scripts I use are included in this project. After going through the quick Vagrant tutorial you'll be ready to try them out:
- Setup the VM on your dev machine: 1_enter_vm.sh
- Provision and test inside the VM: 2_run_inside_vm.sh
- The provision script: 3_provision.sh
Other blog posts
In addition to this project's blog post (Value Objects in Java & Python), you may also be interested in these posts of mine: