unicode string literals and "u" prefix

"Martin v. Löwis" martin at v.loewis.de
Wed Nov 10 08:45:41 CET 2004


nico wrote:
> I think you have the same problem when you write strings in german
> language.

I try to avoid putting non-English messages into source code (Python
or not). Instead, I often put English into source code, then use
gettext to fetch translations.

> Sometimes, I feel like an ethnical minority, when I see in a
> well-known book about Python that "Because Unicode is a relatively
> advanced and rarely used tool, we will omit further details in this
> introductory text."

I do use Unicode strings a lot in my Python applications. However,
I rarely use them in string literals. If I had to put accented/umlauted
characters into a Unicode literal, I had no problems putting u""
in front of the literal.

If you really need a way of declaring all string literals as Unicode,
on a per-module basis, then

from __future__ import string_literals_are_unicode

is an appropriate way of doing this. Of course, it does not work in
the current versions (including 2.4); it doesn't work because nobody
has contributed code to make it work.

So if you really need the feature, please implement it, and submit
the change to sf.net/projects/python. There is nothing wrong with
such a feature - just that nobody has implemented it.
This is how open source works.

Regards,
Martin



More information about the Python-list mailing list