DiffLib Question

Michele Simionato michele.simionato at gmail.com
Wed May 2 05:12:07 EDT 2007


On May 2, 10:46 am, whitewave <fru... at gmail.com> wrote:
> Is there a way for me to disregard
> the newlines and spaces?
>
> Python 2.3
> WINXP
>
> Thanks.
> Jen

HTH:

>> help(difflib.Differ.__init__)
Help on method __init__ in module difflib:

__init__(self, linejunk=None, charjunk=None) unbound difflib.Differ
method
    Construct a text differencer, with optional filters.

    The two optional keyword parameters are for filter functions:

    - `linejunk`: A function that should accept a single string
argument,
      and return true iff the string is junk. The module-level
function
      `IS_LINE_JUNK` may be used to filter out lines without visible
      characters, except for at most one splat ('#').  It is
recommended
      to leave linejunk None; as of Python 2.3, the underlying
      SequenceMatcher class has grown an adaptive notion of "noise"
lines
      that's better than any static definition the author has ever
been
      able to craft.

    - `charjunk`: A function that should accept a string of length 1.
The
      module-level function `IS_CHARACTER_JUNK` may be used to filter
out
      whitespace characters (a blank or tab; **note**: bad idea to
include
      newline in this!).  Use of IS_CHARACTER_JUNK is recommended.


 Michele Simionato




More information about the Python-list mailing list