Python and unicode

Martin v. Loewis martin at
Sun Sep 19 22:01:00 CEST 2010

> One more thing, is there some mechanism to avoid writing all the time
> 'something'.decode('utf-8')?

Yes, use u'something' instead (i.e. put the letter u before the literal,
to make it a unicode literal). Since Python 2.6, you can also put

from __future__ import unicode_literals

at the top of the file to make all string literals Unicode objects.
Since Python 3.0, this is the default (i.e. all string literals
*are* unicode objects).


More information about the Python-list mailing list