title: difflib - ignore whitespace diffs w/ ndiff()?
body: <p>I looked at some answers to similar questions here, but I guess I am still not understanding something about the way <code>difflib.ndiff()</code> works?</p>
  <p>I am looking at <code>ndiff</code> in particular because the documentation implies that, by default, the diff would be ignoring whitespace changes.</p>
  <p>Here's a simple program where I would expect the lines in the Differ (i.e,. the return value from <code>difflib.ndiff()</code>) to be empty:</p>
  <pre><code>import difflib
  
  # a simple set of lines
  A_LINES = [
      'Line 1',
      'Line 2',
  ]
  
  # should be same as A_LINES if whitespace is ignored
  B_LINES = [
      '  Line 1',
      '  Line 2',
  ]
  
  def test_2(a, b):
      # differ = difflib.ndiff(a, b)
      differ = difflib.ndiff(a, b, charjunk=difflib.IS_CHARACTER_JUNK)
      for line in differ:
          print(line)
  
  def main(a_fn, b_fn):
      test_2(A_LINES, B_LINES)
  
  
  if __name__ == '__main__':
      main()
  </code></pre>
  <p><code>difflib.IS_CHARACTER_JUNK()</code> seems to just be a predicate that returns <code>True</code> on <code>' '</code> and <code>'\t'</code>, <code>False</code> otherwise.  Whether you invoke <code>ndiff()</code> by explicitly calling out the <code>IS_CHARACTER_JUNK</code>, or accept the default and not mention the <code>charjunk</code> argument, I get the same output:</p>
  <pre class="lang-none prettyprint-override"><code>- Line 1
  +   Line 1
  ? ++
  
  - Line 2
  +   Line 2
  ? ++
  </code></pre>
  <p>That's not the output I would expect for a diff that is ignoring whitespace.
  It seems very unexpected to me, given the documentation for ndiff (see: <a href="https://docs.python.org/3/library/difflib.html" rel="nofollow noreferrer">https://docs.python.org/3/library/difflib.html</a>).  Is the documentation off, or strange, or wrong, or am I just not understanding something?</p>
  <p>How would I call <code>ndiff()</code> such that there are no lines in the 'differ' generator for this example?</p>
  <p>Any help better understanding how to do <code>&quot;ignore whitespace&quot;-type diffs</code> greatly appreciated.</p>