Skip to main content

Implement comparison magic methods in one line!

Project description

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%

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

comparative-0.0.2.tar.gz (1.9 kB view details)

Uploaded Source

Built Distributions

comparative-0.0.2-py3.7.egg (3.3 kB view details)

Uploaded Source

comparative-0.0.2-py3-none-any.whl (14.7 kB view details)

Uploaded Python 3

File details

Details for the file comparative-0.0.2.tar.gz.

File metadata

  • Download URL: comparative-0.0.2.tar.gz
  • Upload date:
  • Size: 1.9 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for comparative-0.0.2.tar.gz
Algorithm Hash digest
SHA256 b9a6531170d90b7474eb3d6972367ac4e9c308b793bacdc8642c276eda41302d
MD5 a29962cfff8a9190f80e948f645e6874
BLAKE2b-256 923755b8ca5b436536ff74506a87ab7a219e2289f9935e307382cdcc1e124918

See more details on using hashes here.

File details

Details for the file comparative-0.0.2-py3.7.egg.

File metadata

  • Download URL: comparative-0.0.2-py3.7.egg
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for comparative-0.0.2-py3.7.egg
Algorithm Hash digest
SHA256 575a87014d917349b5116ae99ae3e1e709d7ed8a1eb38c59e476f778cc22e3ce
MD5 1bebc5db994d39bb7722cf3c35627fe2
BLAKE2b-256 e1b2beaee3992b8a2a031b3ca63ae44b6f997d86807b7770d11ca79f7d9cb719

See more details on using hashes here.

File details

Details for the file comparative-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: comparative-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 14.7 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for comparative-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 99781716210ccf8a0bfddde066ff0166bc2647ec116c58e5cda3282d88396f1b
MD5 0d43b76713249f5aad3f96c0b71175de
BLAKE2b-256 a6704a1161e98a3c2e38c0dd7edf33b15db2005c2d454eeb79e68b2231e133eb

See more details on using hashes here.

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