Conditional for...in failing with utf-8, Spanish book translation

Stefan Behnel stefan_ml at behnel.de
Mon Apr 21 03:00:28 EDT 2008


Hunter wrote:
> I've narrowed the problem down to a simple test program. Check this out:
> 
> ---
> 
> # -*- coding: utf-8 -*-
> 
> acceptable = "abcdefghijklmnopqrstuvwxyzóíñú" # this line will work
> acceptable = "abcdefghijklmnopqrstuvwxyzóíñúá" # this line won't

[bad words stripped]

this should read

    acceptable = u"abcdefghijklmnopqrstuvwxyzóíñú"
    acceptable = u"abcdefghijklmnopqrstuvwxyzóíñúá"

Mind the little "u" before the string, which makes it a unicode string instead
of an encoded byte string.

http://docs.python.org/tut/node5.html#SECTION005130000000000000000

Stefan



More information about the Python-list mailing list