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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Filename, size | File type | Python version | Upload date | Hashes |
---|---|---|---|---|
Filename, size comparative-0.0.2-py3.7.egg (3.3 kB) | File type Egg | Python version 3.7 | Upload date | Hashes View |
Filename, size comparative-0.0.2-py3-none-any.whl (14.7 kB) | File type Wheel | Python version py3 | Upload date | Hashes View |
Filename, size comparative-0.0.2.tar.gz (1.9 kB) | File type Source | Python version None | Upload date | Hashes View |
Close
Hashes for comparative-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 99781716210ccf8a0bfddde066ff0166bc2647ec116c58e5cda3282d88396f1b |
|
MD5 | 0d43b76713249f5aad3f96c0b71175de |
|
BLAKE2-256 | a6704a1161e98a3c2e38c0dd7edf33b15db2005c2d454eeb79e68b2231e133eb |