Skip to content

Commit 434ab83

Browse files
committed
Added Python 3 implementation of cmp
1 parent ca05631 commit 434ab83

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

domdf_python_tools/utils.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,3 +280,16 @@ def __contains__(self, key):
280280
key = "_False"
281281

282282
return dict.__contains__(self, key)
283+
284+
285+
def cmp(x, y):
286+
"""
287+
Implementation of cmp for Python 3
288+
289+
Compare the two objects x and y and return an integer according to the outcome.
290+
The return value is negative if x < y, zero if x == y and strictly positive if x > y.
291+
292+
:rtype: int
293+
"""
294+
295+
return int((x > y) - (x < y))

0 commit comments

Comments
 (0)