Reverse argument order for nsmallest() and nlargest().

Reads better when the iterable is a generator expression.
This commit is contained in:
Raymond Hettinger 2004-06-15 23:53:35 +00:00
parent 969297f488
commit aefde435ef
4 changed files with 9 additions and 9 deletions

View file

@ -705,7 +705,7 @@ def get_close_matches(word, possibilities, n=3, cutoff=0.6):
result.append((s.ratio(), x))
# Move the best scorers to head of list
result = heapq.nlargest(result, n)
result = heapq.nlargest(n, result)
# Strip scores for the best n matches
return [x for score, x in result]