Python Glossary Русский

all Python 3difflibfunction

difflib.IS_CHARACTER_JUNK()

junk filters

A filter for junk characters: True for a space or a tab. It is the default charjunk of ndiff().

Syntax

difflib.IS_CHARACTER_JUNK(ch)

That is why ndiff() does not latch onto spaces when building '? ' hints: indentation differences are still shown, but spaces never become anchor points of a match. A newline is not junk. Differ() does not use this function by default, which explains why ndiff and Differ output can differ.

Examples

import difflib
print([difflib.IS_CHARACTER_JUNK(c) for c in (' ', '\t', '\n', 'x')])  # → [True, True, False, False]

See also

Open in the full glossarydocs.python.orgReport an inaccuracy