Using difflib to compare text ignoring whitespace differences

Neilen Marais nmarais at sun.ac.za
Tue Dec 19 09:53:31 EST 2006


Hi

I'm trying to compare some text to find differences other than whitespace.
I seem to be misunderstanding something, since I can't even get a basic
example to work:

In [104]: d = difflib.Differ(charjunk=difflib.IS_CHARACTER_JUNK)

In [105]: list(d.compare(['  a'], ['a']))
Out[105]: ['-   a', '+ a']

Surely if whitespace characters are being ignored those two strings should
be marked as identical? What am I doing wrong?

Thanks
Neilen

-- 
you know its kind of tragic 
we live in the new world
but we've lost the magic
-- Battery 9 (www.battery9.co.za)




More information about the Python-list mailing list