On Fri, 19 Mar 2010 09:55:06 pm Karjer Jdfjdf wrote:
> With difflib.context_diff it is possible to write the context to
> files.
>
> difflib.context_diff(a, b[, fromfile][, tofile][, fromfiledate][,
> tofiledate][, n][, lineterm])
>
> Is it also possible to do this to seperate string-objects instead of
> writing them to files?


Use StringIO objects, which are fake files that can be read as strings.

Untested and entirely from memory, use:

from StringIO import StringIO
fromfile = StringIO("some text goes here")
tofile = StringIO("some different text goes here")




-- 
Steven D'Aprano
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to