Skip to main content

Python value object implementation

Project description

About

Abstract base class for python value objects.

Usage

Extend and implement the is_valid method.

class Weight(ValueObject):
    def is_valid(self, value: int) -> bool:
        return isinstance(value, int) and value >= 0

Equality example:

o = Weight(10)
p = Weight(11)
q = Weight(11)

print('o ', o)
print('p ', p)
print('q ', q)
print('o == p ', o == p)
print('o == q ', o == q)
print('p == q ', p == q)

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

pythonvalueobject-1.0.0.tar.gz (2.8 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