2to3 and maketrans

Gregory Ewing greg.ewing at canterbury.ac.nz
Thu Mar 3 01:58:29 EST 2011


What is the recommended way to write code for 2.7 using
maketrans() on text strings in such a way that it will
convert correctly using 2to3?

There seems to be two versions of maketrans in 3.x, one
for text and one for bytes. Code that references
string.maketrans ends up with the one for bytes, which
is not what I want. But I can't write str.maketrans,
because that doesn't exist in 2.x.

So what am I supposed to do?

-- 
Greg



More information about the Python-list mailing list