[Tutor] A unicode print question

Jerry Hill malaclypse2 at gmail.com
Fri Jul 30 21:26:33 CEST 2010


On Fri, Jul 30, 2010 at 1:33 PM, Joel Goldstick <joel.goldstick at gmail.com>wrote:

> I was reading this: http://diveintopython.org/xml_processing/unicode.html
>
> and tried the exercise:
>
<snip>

> But oddly enough, when I typed it into my python shell I did NOT get the
> UnicodeError, and I wonder why not:
>

I believe that python is checking the encoding for stdout.  Try this:

print sys.stdout.encoding

When you attempt to print a unicode string, python will attempt to encode it
based on what it autodetected about your terminal.

-- 
Jerry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100730/2b7446d5/attachment.html>


More information about the Tutor mailing list