[issue21344] save scores or ratios in difflib get_close_matches
Russell Ballestrini
report at bugs.python.org
Thu Apr 24 17:53:00 CEST 2014
Russell Ballestrini added the comment:
New function in difflib: get_scored_matches()
This function acts just like the existing get_close_matches()
function however instead of returning a list of words, it
returns a list of tuples (score, word) pairs.
This gives the end-user the ability to access the
computationally expensive scores/ratios produced as a by-product.
The new usage does _not_ impact backward compatibility::
>>> import difflib
>>> import keyword as _keyword
>>> difflib.get_scored_matches("wheel", _keyword.kwlist)
[(0.6, 'while')]
>>> difflib.get_close_matches("wheel", _keyword.kwlist)
['while']
HG: Enter commit message. Lines beginning with 'HG:' are removed.
HG: Leave message empty to abort commit.
HG: --
HG: user: RussellBallestrini
HG: branch 'default'
changed Lib/difflib.py
----------
Added file: http://bugs.python.org/file35024/difflib-patch-to-save-scores-2.patch
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21344>
_______________________________________
More information about the Python-bugs-list
mailing list