2to3 and maketrans

Gregory Ewing greg.ewing at canterbury.ac.nz
Sat Mar 5 19:46:45 EST 2011


Martin v. Löwis wrote:

> Whether a GUI library is application programming or systems programming,
> I don't know.

Neither do I, but it doesn't really matter. In my case the
string is definitely text (although it will always be ascii)
and therefore unicode is the right representation to use
in 3.x.

I just wondered whether there was a recommended idiom for
using maketrans() on text in 2.7 that 2to3 would translate
into str.maketrans(), but it seems not. Instead the
solution seems to be to convert to unicode and use its
translation method instead.

I've since adopted a different solution, but I'll keep
this in mind for the future. Thanks, everyone.

-- 
Greg



More information about the Python-list mailing list