The IS_CHARACTER_JUNK() function of Python difflib library

Overview:

  • The function IS_CHARACTER_JUNK() function considers the characters space “ ” and “#” as junk and returns True when one of them is passed as the value for the parameter ch.

Example:

# Example Python program that checks

# whether a character is a junk in the

# context of the difflib module

 

import difflib

 

testChar = '%'

isJunk = difflib.IS_CHARACTER_JUNK(testChar)

print("Is character \'{}\' junk:{}".format(testChar, isJunk))

 

testChar = ' '

isJunk = difflib.IS_CHARACTER_JUNK(testChar)

print("Is character \'{}\' junk:{}".format(testChar, isJunk))

Output:

Is character '%' junk:False
Is character ' ' junk:True

 


Copyright 2026 © pythontic.com