A simply newbie question about ndiff

David Goodger goodger at users.sourceforge.net
Sun Apr 21 21:23:47 EDT 2002


Neville Franks wrote:
> I still can't get ndiff to work. If I enter: 'difflib.ndiff' I get
> 'AttributeError: 'difflib' module has no attribute 'ndiff'

Tim Peters' ndiff.py is a script in the tools/scripts directory.
Originally, it was self-contained, but at some point Tim migrated the
SequenceMatcher class into the difflib module.  I extracted the rest of the
generic code and turned it into the difflib.Differ class and difflib.ndiff()
convenience function, Tim converted it to use generators, and it was
released with Python 2.2.  You're running Python 2.1.2, so difflib.ndiff
doesn't exist yet.  You'll have to upgrade to get the full functionality.
You can't use the Python 2.2 difflib module in Python 2.1, because it uses
the generator feature, new to Python 2.2.  However, you can get a Python
2.0/2.1-compatible version from
http://docutils.sourceforge.net/test/difflib.py; this is the module after I
added Differ and ndiff(), but before Tim converted it to use generators.

-- 
David Goodger  <goodger at users.sourceforge.net>  Open-source projects:
  - Python Docutils: http://docutils.sourceforge.net/
  - The Go Tools Project: http://gotools.sourceforge.net/




More information about the Python-list mailing list