New submission from bob gailer: 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. ---------- assignee: docs@python components: Documentation messages: 216630 nosy: bgailer, docs@python priority: normal severity: normal status: open title: str.translate documentation incomplete type: enhancement versions: Python 3.3 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue21279> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com