On this page
  1. difflib.ndiff
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

difflib.ndiff

Prev: difflib.Match | Up: difflib | Next: difflib.restore
Rel: difflib.context_diff, difflib.diff_bytes, difflib.Differ, difflib.get_close_matches
Ref: docs.python.org — difflib.ndiff
Tags: #public #python3 #stdlib #difflib


Import

import difflib
from difflib import ndiff

Signature & Overview

difflib.ndiff(a, b, linejunk=None, charjunk=<function IS_CHARACTER_JUNK at 0x109cd6140>)

Compare a and b (lists of strings); return a Differ-style delta.

Usage

import difflib

diff = list(difflib.ndiff(["one\n", "two\n"], ["one\n", "too\n"]))
assert "- two\n" in diff and "+ too\n" in diff

Gotchas

REPL Inspect

from difflib import ndiff
help(ndiff)

Linked from

Related notes