WTF? Printing unicode strings

Robert Kern robert.kern at gmail.com
Thu May 18 23:55:59 CEST 2006


Ron Garret wrote:

> I forgot to mention:
> 
>>>>sys.getdefaultencoding()
> 
> 'utf-8'

A) You shouldn't be able to do that.
B) Don't do that.
C) It's not relevant to the encoding of stdout which determines how unicode
strings get converted to bytes when printing them:

>>> import sys
>>> sys.stdout.encoding
'UTF-8'
>>> sys.getdefaultencoding()
'ascii'
>>> print u'\xbd'
½

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco




More information about the Python-list mailing list