[Python-modules-commits] [geopy] 02/06: Use __lt__() and __eq__() instead of __cmp__() and cmp()
Daniele Tricoli
eriol-guest at moszumanska.debian.org
Fri Nov 6 15:34:16 UTC 2015
This is an automated email from the git hooks/post-receive script.
eriol-guest pushed a commit to branch master
in repository geopy.
commit 285387babdd8f465613ccdd0c24d8be0d40f44b1
Author: Daniele Tricoli <eriol at mornie.org>
Date: Thu Oct 8 09:14:11 2015 -0700
Use __lt__() and __eq__() instead of __cmp__() and cmp()
Last-Update: 2014-02-13
Patch-Name: 04_use_lt_and_eq_instead_of_cmp.patch
---
geopy/distance.py | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/geopy/distance.py b/geopy/distance.py
index 3530148..07ae215 100644
--- a/geopy/distance.py
+++ b/geopy/distance.py
@@ -162,11 +162,17 @@ class Distance(object):
def __str__(self): # pragma: no cover
return '%s km' % self.__kilometers
- def __cmp__(self, other):
+ def __lt__(self, other):
if isinstance(other, Distance):
- return cmp(self.kilometers, other.kilometers)
+ return self.kilometers < other.kilometers
else:
- return cmp(self.kilometers, other)
+ return self.kilometers < other
+
+ def __eq__(self, other):
+ if isinstance(other, Distance):
+ return self.kilometers == other.kilometers
+ else:
+ return self.kilometers == other
@property
def kilometers(self): # pylint: disable=C0111
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/geopy.git
More information about the Python-modules-commits
mailing list