unicode

7stud bbxx789_05ss at yahoo.com
Sun Jul 1 23:51:56 EDT 2007


Hi,

Thanks for the detailed response.

On Jul 1, 2:14 pm, "Martin v. Löwis" <mar... at v.loewis.de> wrote:
> > 1) If you print a unicode string:
> >
> > a) str() calls encode(), and encode() tries to convert the unicode
> > string to a regular string.  encode() uses the default encoding, which
> > is ascii.  If encode() can't convert a character, then encode() raises
> > an exception.
>
> Yes and no. This is what str() does, but str() isn't called. Instead,
> print inspects sys.stdout.encoding, and uses that encoding to encode
> the string. That, in turn, may raise an exception (in particular if
> sys.stdout.encoding is "ascii" or not set).
>

Is that the same as print calling encode(u_str, sys.stdout.encoding)





More information about the Python-list mailing list