[Python-Dev] "data".decode(encoding) ?!

Michael Hudson mwh@python.net
09 May 2001 21:13:46 +0100


"M.-A. Lemburg" <mal@lemburg.com> writes:

> I've attached the patch. Due to a small reorganisation the patch is
> a little longer -- symmetry has its price at C level too ;-)

I may be being dense, but can you explain what's going on here:

->> u'\u00e3'.encode('latin-1')
'\xe3'
->> u'\u00e3'.encode("latin-1").decode("latin-1")
Traceback (most recent call last):
  File "<input>", line 1, in ?
UnicodeError: ASCII encoding error: ordinal not in range(128)

Can you come up with some other example I can use it tomorrow's
python-dev summary?

Cheers,
M.

-- 
  Remember - if all you have is an axe, every problem looks 
  like hours of fun.                                        -- Frossie
               -- http://home.xnet.com/~raven/Sysadmin/ASR.Quotes.html