On this page
  1. difflib.Differ
  2. Import
  3. Signature & Overview
  4. Methods & Attributes
  5. Usage
  6. Gotchas
  7. REPL Inspect

difflib.Differ

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


Import

import difflib
from difflib import Differ

Signature & Overview

difflib.Differ(linejunk=None, charjunk=None)

Differ is a class for comparing sequences of lines of text, and producing human-readable differences or deltas. Differ uses SequenceMatcher both to compare sequences of lines, and to compare

Methods & Attributes

Usage

import difflib

diff = list(difflib.Differ().compare(["a\n", "b\n"], ["a\n", "c\n"]))
assert "- b\n" in diff and "+ c\n" in diff

Gotchas

REPL Inspect

from difflib import Differ
help(Differ)

Linked from

Related notes