Fredrik Lundh wrote: > hg wrote: > >> We noticed that len('à') != len('a') > > sounds odd. > >>>> len('à') == len('a') > True > > are you perhaps using an UTF-8 editor? > > to keep your sanity, no matter what editor you're using, I recommend > adding a coding directive to the source file, and using *only* Unicode > string literals for non-ASCII text. > > or in other words, put this at the top of your file (where "utf-8" is > whatever your editor/system is using): > > # -*- coding: utf-8 -*- > > and use > > u'<text>' > > for all non-ASCII literals. > > </F> >
Hi, The problem is that: # -*- coding: utf-8 -*- import string print len('a') print len('à') returns 1 then 2 and string.maketrans(str1, str2) requires that len(str1) == len(str2) hg -- http://mail.python.org/mailman/listinfo/python-list