all Python 3difflibfunction
difflib.IS_LINE_JUNK()
junk filters
A filter for junk lines: True for a blank line and for a line holding only '#' and whitespace.
Syntax
difflib.IS_LINE_JUNK(line)
Despite the name, ndiff() does not use it by default: its linejunk is None. To stop blank lines and lone '#' from acting as match anchors, pass linejunk=difflib.IS_LINE_JUNK explicitly. A line of code with a comment (x = 1 # ok) is not considered junk.
Examples
import difflib
print(difflib.IS_LINE_JUNK('\n'), difflib.IS_LINE_JUNK(' # \n'), difflib.IS_LINE_JUNK('x = 1\n')) # → True True False
See also
Open in the full glossarydocs.python.orgReport an inaccuracy