Mercurial > cpython-lru_cache-weakref
comparison Doc/lib/libstring.tex @ 29893:e9dddfd2a62f legacy-trunk
Discussion of signatures for unicode.translate() and str.translate()
were in the wrong file. Moved out of libstring.tex and into
libstdtypes.tex.
| author | Raymond Hettinger <python@rcn.com> |
|---|---|
| date | Wed, 16 Jul 2003 05:11:27 +0000 |
| parents | d45d317fda35 |
| children | 8941f2ee9094 |
comparison
equal
deleted
inserted
replaced
| 29892:79ec7e302d53 | 29893:e9dddfd2a62f |
|---|---|
| 275 \begin{funcdesc}{translate}{s, table\optional{, deletechars}} | 275 \begin{funcdesc}{translate}{s, table\optional{, deletechars}} |
| 276 Delete all characters from \var{s} that are in \var{deletechars} (if | 276 Delete all characters from \var{s} that are in \var{deletechars} (if |
| 277 present), and then translate the characters using \var{table}, which | 277 present), and then translate the characters using \var{table}, which |
| 278 must be a 256-character string giving the translation for each | 278 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). | |
| 290 \end{funcdesc} | 280 \end{funcdesc} |
| 291 | 281 |
| 292 \begin{funcdesc}{upper}{s} | 282 \begin{funcdesc}{upper}{s} |
| 293 Return a copy of \var{s}, but with lower case letters converted to | 283 Return a copy of \var{s}, but with lower case letters converted to |
| 294 upper case. | 284 upper case. |
