Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5c5fca9

Browse files
committed
SF bug #706546: u''.translate not documented
Clarified the difference between translate methods for string objects and Unicode objects.
1 parent 1d8d729 commit 5c5fca9

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

Doc/lib/libstring.tex

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,17 @@ \section{\module{string} ---
276276
Delete all characters from \var{s} that are in \var{deletechars} (if
277277
present), and then translate the characters using \var{table}, which
278278
must be a 256-character string giving the translation for each
279-
character value, indexed by its ordinal.
279+
character value, indexed by its ordinal.
280+
281+
For Unicode objects, the \method{translate()} method does not
282+
accept the optional \var{deletechars} argument. Instead, it
283+
returns a copy of the \var{s} where all characters have been mapped
284+
through the given translation table which must be a mapping of
285+
Unicode ordinals to Unicode ordinals, Unicode strings or \code{None}.
286+
Unmapped characters are left untouched. Characters mapped to \code{None}
287+
are deleted. Note, a more flexible approach is to create a custom
288+
character mapping codec using the \refmodule{codecs} module (see
289+
\module{encodings.cp1251} for an example).
280290
\end{funcdesc}
281291

282292
\begin{funcdesc}{upper}{s}

0 commit comments

Comments
 (0)