String similarity: An overlooked but very handy Python function

I’m willing to bet a large number of Python devs have never used (and maybe not even heard of) the standard library’s difflib module.

However, tucked away in what seems like a module with for a rather particular use-case is a handy function called get_close_matches.

Quoting from the docs:

get_close_matches('appel', ['ape', 'apple', 'peach', 'puppy'])
>>> ['apple', 'ape']

Additionally you can specify the maximum number of results and a cutoff similarity level.

Handy to have this for free, eh?