[Tutor] difflib - restoring from a unified diff?

Kent Johnson kent37 at tds.net
Sun Oct 1 15:50:50 CEST 2006

Liam Clarke wrote:
> Hi all,
> I'm writing a wiki at the moment, and I want to store unified diffs to 
> allow easy reverting between versions of a document. It appears that 
> difflib.restore() can only generate original text from diffs returned 
> from ndiff() or compare() which store the full text of both versions.
> As this offers no efficiency in storage space over storing the actual 
> text, it doesn't much serve my purpose - does anyone know of a 3rd party 
> module that, given a text and a unified diff, can return the altered 
> text? I can probably write one myself if I sweat a bit, but I'd much 
> rather use any pre-existing modules.

I don't see a python module for this but you could use os.system() to 
invoke patch.


More information about the Tutor mailing list