string.maketrans().lower()
Erik Max Francis
max at alcyone.com
Tue Aug 31 23:11:28 EDT 2004
Hallvard B Furuseth wrote:
> I have a translation table from
> tr = string.maketrans(...)
> and want a table which produces the same characters lowercased.
>
> `tr.lower()' works - at least with Python 2.3 - but is that will
> that remain reliable? Or should I use something like this?
>
> string.maketrans("".join(map(chr, xrange(256))),
> "".join(map(chr, xrange(256))).translate(tr).lower())
Sure. The return value of string.maketrans is just itself a string,
after all.
> BTW, is there a simpler way to write "".join(map(chr, xrange(256)))?
You could use a list comprehension if you prefer.
--
__ Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
/ \ San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
\__/ Procrastination is the thief of time.
-- Edward Young
More information about the Python-list
mailing list