Message216630
| 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:22 | bgailer | set | recipients:
+ bgailer, docs@python |
| 2014年04月17日 01:01:22 | bgailer | set | messageid: <1397696482.87.0.486412592823.issue21279@psf.upfronthosting.co.za> |
| 2014年04月17日 01:01:22 | bgailer | link | issue21279 messages |
| 2014年04月17日 01:01:21 | bgailer | create |
|