what is this UnicodeDecodeError:....?

John Machin sjmachin at lexicon.net
Tue Oct 10 23:32:59 CEST 2006


Marc 'BlackJack' Rintsch wrote:

> Because you are trying to compare a unicode string `val` with a byte
> string in the list. The unicode string will be converted to a byte string
> for this comparison with the default encoding: ASCII.

:-)

I presume you must live north of the equator. Down under, it seems to
happen the other way up -- the byte strings are decoded to unicode:

| >>> ['a', 'exotic1\xff', 'exotic2\xf3'].index(u'\xf3')
| Traceback (most recent call last):
|   File "<stdin>", line 1, in ?
| UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position
7: ordinal not in range(128)

(-:




More information about the Python-list mailing list