Skip to main content

comparative

Implement comparison magic methods in one line!

Usage

from comparative import compare_by

@compare_by("hour", "minute", "second")
class Clock:

    def __int__(self, hour=0, minute=0, second=0):
        self.hour = hour
        self.minute = mintue
        self.second = second

    def __repr__(self):
        return ("Clock(h={0.hour:}, m={0.minute:02d}, "
                "s={0.second:02d})").format(self)

    def __str__(self):
        return "{0.hour:02d}:{0.minute:02d}:{0.second:02d}".format(self)

Just Add Water

>>> clock1 = Clock(8, 0, 0)
>>> clock2 = Clock(8, 0, 1)
>>> clock3 = Clock(8, 0, 0)
>>> clock1 < clock2
True
>>> clock1 == clock2
False
>>> clock1 == clock3
True

t@o55bhDr%

Metadata

Release files for comparative 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for comparative 0.0.2
File Size Uploaded
comparative-0.0.2.tar.gz 1.9 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for comparative 0.0.2
File Interpreter ABI Platform
comparative-0.0.2-py3.7.egg Legacy Egg format - - Details
comparative-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 19.9 kB

Release files / comparative-0.0.2.tar.gz

Download URL comparative-0.0.2.tar.gz
Size 1.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b9a6531170d90b7474eb3d6972367ac4e9c308b793bacdc8642c276eda41302d
BLAKE2b-256 checksum
How to use checksums
923755b8ca5b436536ff74506a87ab7a219e2289f9935e307382cdcc1e124918
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

Release files / comparative-0.0.2-py3.7.egg

Download URL comparative-0.0.2-py3.7.egg
Size 3.3 kB
Tags Egg
SHA-256 checksum
How to use checksums
575a87014d917349b5116ae99ae3e1e709d7ed8a1eb38c59e476f778cc22e3ce
BLAKE2b-256 checksum
How to use checksums
e1b2beaee3992b8a2a031b3ca63ae44b6f997d86807b7770d11ca79f7d9cb719
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

Release files / comparative-0.0.2-py3-none-any.whl

Download URL comparative-0.0.2-py3-none-any.whl
Size 14.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
99781716210ccf8a0bfddde066ff0166bc2647ec116c58e5cda3282d88396f1b
BLAKE2b-256 checksum
How to use checksums
a6704a1161e98a3c2e38c0dd7edf33b15db2005c2d454eeb79e68b2231e133eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

Release history Release notifications | RSS feed

This release

0.0.2 This release

3 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page