summaryrefslogtreecommitdiffstats
path: root/Doc/library
diff options
context:
space:
mode:
authorZachary Ware <zachary.ware@gmail.com>2015-08-06 05:05:13 (GMT)
committerZachary Ware <zachary.ware@gmail.com>2015-08-06 05:05:13 (GMT)
commit070bd62cfa144bfa62ec7766a936d9c7b360861b (patch)
tree813ab1a48c6454f860357abbe38cf9422a04e3af /Doc/library
parentc7c66c91427734dcdb34ae78eee2431e92fa6f07 (diff)
parentd987a81d29a16215fff6dd9670cedbcdac82d1b0 (diff)
downloadcpython-070bd62cfa144bfa62ec7766a936d9c7b360861b.zip
cpython-070bd62cfa144bfa62ec7766a936d9c7b360861b.tar.gz
cpython-070bd62cfa144bfa62ec7766a936d9c7b360861b.tar.bz2
Closes #21279: Merge with 3.5
Diffstat (limited to 'Doc/library')
-rw-r--r--Doc/library/stdtypes.rst21
1 files changed, 11 insertions, 10 deletions
diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
index 2c6e7c6..1ae1693 100644
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -1986,21 +1986,22 @@ expression support in the :mod:`re` module).
"They're Bill's Friends."
-.. method:: str.translate(map)
+.. method:: str.translate(table)
- Return a copy of the *s* where all characters have been mapped through the
- *map* which must be a dictionary of Unicode ordinals (integers) to Unicode
- ordinals, strings or ``None``. Unmapped characters are left untouched.
- Characters mapped to ``None`` are deleted.
+ Return a copy of the string in which each character has been mapped through
+ the given translation table. The table must be an object that implements
+ indexing via :meth:`__getitem__`, typically a :term:`mapping` or
+ :term:`sequence`. When indexed by a Unicode ordinal (an integer), the
+ table object can do any of the following: return a Unicode ordinal or a
+ string, to map the character to one or more other characters; return
+ ``None``, to delete the character from the return string; or raise a
+ :exc:`LookupError` exception, to map the character to itself.
You can use :meth:`str.maketrans` to create a translation map from
character-to-character mappings in different formats.
- .. note::
-
- An even more flexible approach is to create a custom character mapping
- codec using the :mod:`codecs` module (see :mod:`encodings.cp1251` for an
- example).
+ See also the :mod:`codecs` module for a more flexible approach to custom
+ character mappings.
.. method:: str.upper()