[ python-Feature Requests-1592899 ] "".translate() docs should mention string.maketrans()

SourceForge.net noreply at sourceforge.net
Thu Dec 7 10:30:30 CET 2006


Feature Requests item #1592899, was opened at 2006-11-08 20:23
Message generated for change (Comment added) made by gbrandl
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1592899&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Documentation
Group: Python 2.6
>Status: Closed
>Resolution: Fixed
Priority: 5
Private: No
Submitted By: Ori Avtalion (salty-horse)
Assigned to: Raymond Hettinger (rhettinger)
Summary: "".translate() docs should mention string.maketrans()

Initial Comment:
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.

----------------------------------------------------------------------

>Comment By: Georg Brandl (gbrandl)
Date: 2006-12-07 09:30

Message:
Logged In: YES 
user_id=849994
Originator: NO

Cleared up both items in rev. 52951, 52952 (2.5).

----------------------------------------------------------------------

Comment By: Fredrik Lundh (effbot)
Date: 2006-12-04 17:42

Message:
Logged In: YES 
user_id=38376
Originator: NO

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.

----------------------------------------------------------------------

Comment By: Ori Avtalion (salty-horse)
Date: 2006-12-04 17:08

Message:
Logged In: YES 
user_id=854801
Originator: YES

>"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.

----------------------------------------------------------------------

Comment By: Fredrik Lundh (effbot)
Date: 2006-12-04 09:20

Message:
Logged In: YES 
user_id=38376
Originator: NO

"re.compile should mention maketrans as well"

why?

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1592899&group_id=5470


More information about the Python-bugs-list mailing list