How fuzzy is get_close_matches() in difflib?

Steven D'Aprano steve at REMOVEME.cybersource.com.au
Fri Nov 17 03:06:05 CET 2006


On Thu, 16 Nov 2006 16:40:49 -0800, John Henry wrote:

> I am just wondering what's with get_close_matches() in difflib.  What's
> the magic?   How fuzzy do I need to get in order to get a match?


Why don't you try it and see?

>>> from difflib import get_close_matches
>>> get_close_matches("appel", ["ape", "apple", "peach", "puppy"])
['apple', 'ape']
>>> import keyword as _keyword
>>> get_close_matches("wheel", _keyword.kwlist)
['while']
>>> get_close_matches("apple", _keyword.kwlist)
[]
>>> get_close_matches("accept", _keyword.kwlist)
['except']


Those example, by the way, come from here:

>>> help(get_close_matches)




-- 
Steven




More information about the Python-list mailing list