string.printable unchanged by locale

Martin v. Loewis martin at v.loewis.de
Sun Nov 3 06:18:07 EST 2002


Magnus Lyckå <magnus at thinkware.se> writes:

> Is this intentional or a bug?

It's a bug. However, it is not clear what the fix is: probably
deprecate string.printable altogether. By design, it cannot work for
multi-byte encodings, so it is questionable what good it would be to
make it locale-dependent.

The same applies, of course, to string.letters, etc. I would recommend
to use Unicode categories instead. I.e. convert the strings to
Unicode, then use the value returned from unicodedata.category to
determine whether something is "printable". Notice that being
"printable" is a fuzzy property - pick a definition that suits your
application best.

Regards,
Martin




More information about the Python-list mailing list