A translation table maps source characters to replacement characters for character-by-character text translation. Python's maketrans creates the table, and translate applies it across a string. section 6.4.5
The core rules are:
- Pass two equally long strings to maketrans; the nth character in the first maps to the nth character in the second. section 6.4.5
- Pass the resulting table to translate; each character found in the table is replaced with its mapped character. section 6.4.5
- Supply empty first and second strings plus a third string to remove listed characters, such as punctuation. section 6.4.5
- Create the table once before a loop rather than rebuilding it for every input line; repeated construction can reduce efficiency. section 6.10.2
Translate operators and brackets
For x = "~x ^ (y % z)", x.maketrans("~^()", "!&[]") followed by x.translate(table) produces "!x & [y % z]". A deletion table can instead remove characters such as "()~^%", producing "x y z".

