Translation table
A translation table is a mapping from source items to corresponding replacement, standardized, or translated values.
The Quick Python Book, Fourth Edition
A translation table is a mapping from source characters to replacement characters used for character-by-character text translation.
- How it is used
- Translates strings efficiently when many character substitutions or removals must be applied consistently.
- How deep it goes
- Explains table construction, indexed character mapping, application, deletion, and loop-efficiency trade-offs.
- Examples
- Demonstrates operator conversion, character deletion, and punctuation removal while cleaning a text file.
- What you can do after
- Apply it via Python string methods to replace or remove character sets without repeated replace calls.
Read how The Quick Python Book, Fourth Edition explains translation table →
Tiny Python Projects: Learn coding and testing with puzzles and games
A translation table is a mapping that specifies replacement values for characters processed by a string translation operation.
- How it is used
- Uses character mappings to perform whole-string replacement in one str.translate() operation.
- How deep it goes
- Defines table creation and lookup behavior, including unchanged and deleted characters, but defers deeper explanation.
- Examples
- Demonstrates digit substitution in 867-5309 and Jenny = 867-5309 while preserving punctuation and letters.
- What you can do after
- Apply it via Python's str.maketrans() and str.translate() to replace or delete selected characters.
Related concepts
- translateused by · str.translate is a Python string method that returns a copy with characters transformed or deleted according to a translation table.
- string moduleused by · The string module is a Python standard-library module providing constants and utilities for processing text and character classes.
- Mapimplemented by · A map is an associative data structure that stores key-value pairs and supports retrieving values by key.
- valueconfigured by · A value is the content, quantity, information, or worth attributed to an entity, property, expression, or outcome.
- keyconfigured by · A key is an identifier or value used to locate or access an associated entry or property in a keyed data structure.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

