[Tutor] PyMOTW: difflib
Alan Gauld
alan.gauld at btinternet.com
Mon Apr 7 01:39:21 CEST 2008
"Dick Moores" <rdm at rcblue.com> wrote
>> > Copied the data into my demo_pymotw-difflib.py,
>> > deleted the line "from difflib_data import *",
>> > and ran it
>>
>>I'm curious. Why did you do that?
> OK, I put it back in, changing the filename to
> demo_pymotw-difflib_error.py.
> See <http://py77.python.pastebin.com/f5c3a37ce> for the code and the
> ImportError: No module named difflib_data.
You still have the copied data which will overwrite the values
imported however to import it you need to have the path set
up correctly. Is the difflib_data.py in the same folder as difflib.py?
Your code should only need to be:
a.. import difflib
a.. from difflib_data import *
a..
a.. d = difflib.Differ()
a.. diff = d.compare(text1_lines, text2_lines)
a.. print '\n'.join(list(diff))
And provided both modules are visible to Python it should work.
Copying the data works too but I was just curious why you
needed to...
Alan G.
More information about the Tutor
mailing list