diff options
author | Samuel Holland <samuel@sholland.org> | 2018-05-10 15:50:17 -0500 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2019-04-08 15:11:57 +0200 |
commit | e40cfb66a19c2bf3b8c01f3e056ea56914aea18c (patch) | |
tree | 574edc071ceb139f004b6e3d62e0143a6e368270 | |
parent | e72b83b240fc37abe369f9a800718ba89ad06d87 (diff) | |
download | wee-slack-e40cfb66a19c2bf3b8c01f3e056ea56914aea18c.tar.gz |
Implement the new comparison methods for SlackTS
Python 3 no longer respects __cmp__, as it has more fine-grained hooks
for ordering/comparison. To minimize code changes, implement them in
terms of the existing __cmp__ method.
-rw-r--r-- | wee_slack.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/wee_slack.py b/wee_slack.py index 33aa919..8b659f6 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -2392,6 +2392,21 @@ class SlackTS(object): elif s == other: return 0 + def __lt__(self, other): + return self.__cmp__(other) < 0 + + def __le__(self, other): + return self.__cmp__(other) <= 0 + + def __eq__(self, other): + return self.__cmp__(other) == 0 + + def __ge__(self, other): + return self.__cmp__(other) >= 0 + + def __gt__(self, other): + return self.__cmp__(other) > 0 + def __hash__(self): return hash("{}.{}".format(self.major, self.minor)) |