mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Let library modules use the new keyword arguments for list.sort().
This commit is contained in:
parent
42b1ba31af
commit
6b59f5f3fd
7 changed files with 18 additions and 24 deletions
|
@ -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):
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue