summaryrefslogtreecommitdiffstats
path: root/Lib/difflib.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2003-10-16 05:53:16 (GMT)
committerRaymond Hettinger <python@rcn.com>2003-10-16 05:53:16 (GMT)
commit6b59f5f3fd9bdf00875a7cead15f423fa1c2f910 (patch)
tree1bd1e055f31e154230ffd962a294d37cf678c87a /Lib/difflib.py
parent42b1ba31aff86af6257a0fca455d5569bce9d8fc (diff)
downloadcpython-6b59f5f3fd9bdf00875a7cead15f423fa1c2f910.zip
cpython-6b59f5f3fd9bdf00875a7cead15f423fa1c2f910.tar.gz
cpython-6b59f5f3fd9bdf00875a7cead15f423fa1c2f910.tar.bz2
Let library modules use the new keyword arguments for list.sort().
Diffstat (limited to 'Lib/difflib.py')
-rw-r--r--Lib/difflib.py12
1 files changed, 4 insertions, 8 deletions
diff --git a/Lib/difflib.py b/Lib/difflib.py
index a45c0bc..699845c 100644
--- a/Lib/difflib.py
+++ b/Lib/difflib.py
@@ -701,15 +701,11 @@ def get_close_matches(word, possibilities, n=3, cutoff=0.6):
s.quick_ratio() >= cutoff and \
s.ratio() >= cutoff:
result.append((s.ratio(), x))
- # Sort by score.
- result.sort()
- # Retain only the best n.
- result = result[-n:]
- # Move best-scorer to head of list.
- result.reverse()
- # Strip scores.
- return [x for score, x in result]
+ # Move the best scorers to head of list
+ result.sort(reverse=True)
+ # Strip scores for the best n matches
+ return [x for score, x in result[:n]]
def _count_leading(line, ch):
"""