Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Python
How fuzzy is get_close_matches() in difflib?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="John Machin, post: 2045574"] On Nov 17, 7:19 pm, Steven D'Aprano <s...@REMOVEME.cybersource.com.au> wrote: [snip] Take 1, firing from the hip: The formatting of that output is suboptimal. Better would be: ' H I D E -D +S C T 1' interpreted as "delete D, insert S" ' H I D E -D S +C T 1' interpreted as "delete D, insert C" After reflection that the author of difflib is known not to be so silly, take 2: | >>> list(difflib.Differ().compare("HIDEDCT1", "HIDESCT1")) [' H', ' I', ' D', ' E', '- D', '+ S', ' C', ' T', ' 1'] And the docs shed some light on what is going on: | >>> help(difflib.Differ().compare) Help on method compare in module difflib: compare(self, a, b) method of difflib.Differ instance Compare two sequences of lines; generate the resulting delta. Each sequence must contain individual single-line strings ending with newlines. Such sequences can be obtained from the `readlines()` method of file-like objects. The delta generated also consists of newline- terminated strings, ready to be printed as-is via the writeline() method of a file-like object. Example: ''.join(Differ().compare('one\ntwo\nthree\n'.splitlines(1), ... 'ore\ntree\nemu\n'.splitlines(1))), - one ? ^ + ore ? ^ - two - three ? - + tree + emu HTH, John [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Python
How fuzzy is get_close_matches() in difflib?
Top