[Patches] string.translate behaviour

Peter Schneider-Kamp peter@schneider-kamp.de
Mon, 29 May 2000 18:00:11 +0200


"M.-A. Lemburg" wrote:
> 
> Note that Unicode uses a new approach here (which I find much
> more useful, BTW):
> 
> """
> S.translate(table) -> unicode
> 
> Return a copy of the string S, where all characters have been mapped
> through the given translation table, which must be a mapping of
> Unicode ordinals to Unicode ordinals or None. Unmapped characters
> are left untouched. Characters mapped to None are deleted.
> """

Okay, maybe I am missing the point, but if I want to change
a to b, b to c and c to a I would like to write:

s.translate("abc","bca")

But as far as I can see I have to write something like this:

s.translate(range(97)+[98,99,97])

to get this behaviour. Not exactly intuitive.

--
Peter Schneider-Kamp          ++47-7388-7331
Herman Krags veg 51-11        mailto:peter@schneider-kamp.de
N-7050 Trondheim              http://schneider-kamp.de