This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: "".translate() docs should mention string.maketrans()
Type: enhancement Stage:
Components: Documentation Versions: Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: effbot, georg.brandl, rhettinger, salty-horse
Priority: normal Keywords:

Created on 2006-11-08 20:23 by salty-horse, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (5)
msg54935 - (view) Author: Ori Avtalion (salty-horse) * Date: 2006-11-08 20:23
The translate() documentation at
http://docs.python.org/lib/string-methods.html#l2h-268
should mention the string.maketrans helper function.

maketrans also mentions "regex.compile" - that should
probably be "re.compile" (although it's less readable).

re.compile should mention maketrans as well.
msg54936 - (view) Author: Fredrik Lundh (effbot) * (Python committer) Date: 2006-12-04 09:20
"re.compile should mention maketrans as well"

why?
msg54937 - (view) Author: Ori Avtalion (salty-horse) * Date: 2006-12-04 17:08
>"re.compile should mention maketrans as well"
>why?

The maketrans doc says:
"Return a translation table suitable for passing to translate() or regex.compile()"

I don't have any use case for how it's useful to regex.compile. Maybe there is none, and the mention can be removed.
msg54938 - (view) Author: Fredrik Lundh (effbot) * (Python committer) Date: 2006-12-04 17:42
Aha.  The regex documentation says:

compile (pattern[, translate]) /.../ The optional argument translate, if present, must be a 256-character string indicating how characters (both of the pattern and of the strings to be matched) are translated before comparing them; the i-th element of the string gives the translation for the character with ASCII code i. This can be used to implement case-insensitive matching; see the casefold data item below.

which means that it was indeed useful for regex.compile.  afaik, re.compile doesn't support arbitrary mappings, so that reference should be removed.
msg54939 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-12-07 09:30
Cleared up both items in rev. 52951, 52952 (2.5).
History
Date User Action Args
2022-04-11 14:56:21adminsetgithub: 44211
2006-11-08 20:23:20salty-horsecreate