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.

Author bgailer
Recipients bgailer, docs@python
Date 2014-04-17.01:01:21
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1397696482.87.0.486412592823.issue21279@psf.upfronthosting.co.za>
In-reply-to
Content
Documentation for str.translate only mentions a dictionary for the translation table. Actually any iterable can be used, as long as its elements are integer, None or str.

Recommend wording:

str.translate(translation_table)

Return a copy of the s where all characters have been "mapped" through the translation_table - which must be either a dictionary mapping Unicode ordinals (integers) to Unicode ordinals, strings or None,
or an iterable. In this case the ord() of each character in s is used as an index into the iterable; the corresponding element of the iterable replaces the character. If ord() of the character exceeds the index range of the iterator, no substitution is made.

Example: to shift any of the first 255 ASCII characters to the next:

>>> 'Now is the time for all good men'.translate(range(1, 256))
'Opx!jt!uif!ujnf!gps!bmm!hppe!nfo'

COMMENT: I placed mapped in quotes as technically this only applies to dictionaries. Not sure what the best word is.
History
Date User Action Args
2014-04-17 01:01:22bgailersetrecipients: + bgailer, docs@python
2014-04-17 01:01:22bgailersetmessageid: <1397696482.87.0.486412592823.issue21279@psf.upfronthosting.co.za>
2014-04-17 01:01:22bgailerlinkissue21279 messages
2014-04-17 01:01:21bgailercreate