mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
bpo-39481: PEP 585 for difflib, filecmp, fileinput (#19422)
This commit is contained in:
parent
7c4185d62d
commit
e3ec44d692
4 changed files with 17 additions and 0 deletions
|
@ -32,6 +32,7 @@ __all__ = ['get_close_matches', 'ndiff', 'restore', 'SequenceMatcher',
|
|||
|
||||
from heapq import nlargest as _nlargest
|
||||
from collections import namedtuple as _namedtuple
|
||||
from types import GenericAlias
|
||||
|
||||
Match = _namedtuple('Match', 'a b size')
|
||||
|
||||
|
@ -685,6 +686,9 @@ class SequenceMatcher:
|
|||
# shorter sequence
|
||||
return _calculate_ratio(min(la, lb), la + lb)
|
||||
|
||||
__class_getitem__ = classmethod(GenericAlias)
|
||||
|
||||
|
||||
def get_close_matches(word, possibilities, n=3, cutoff=0.6):
|
||||
"""Use SequenceMatcher to return list of the best "good enough" matches.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue