[Python-ideas] A suggested feature for difflib
Chris Rose
offline at offby1.net
Sat Feb 15 18:25:58 CET 2014
More information about the Python-ideas mailing list
Sat Feb 15 18:25:58 CET 2014
- Previous message: [Python-ideas] Enhance exceptions by attaching some more information to them
- Next message: [Python-ideas] A suggested feature for difflib
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Right now, any alternative SequenceMatcher implementation in difflib
requires that the implementor also reimplement the diff formatting methods
(unified_diff and context_diff).
I propose something along these lines (patch to follow if the idea is
sound):
class Differ:
def __init__(self, linejunk=None, charjunk=None,
sequence_matcher_factory=SequenceMatcher):
# and so on
def compare(self, a, b):
cruncher = self.sequence_matcher_factory(self.linejunk, a, b)
# and so on
The same general idea with unified_diff, ndiff, and context_diff
Basically, there are two obvious points of extension in difflib: The
formatting of the output opcodes, and the method used to find sequences.
The latter is not easily extended while reusing the former, and I'd like to
change that. Note that I'm asking because I'd like to do the work, not
because I want someone else to do it.
Is this a reasonable idea?
--
Chris R.
======
Not to be taken literally, internally, or seriously.
Twitter: http://twitter.com/offby1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140215/e6234f4a/attachment.html>
- Previous message: [Python-ideas] Enhance exceptions by attaching some more information to them
- Next message: [Python-ideas] A suggested feature for difflib
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-ideas mailing list