unicode question

"Martin v. Löwis" martin at v.loewis.de
Sat Nov 20 23:48:29 CET 2004


wolfgang haefelinger wrote:
> I wonder especially about case 2. I can see that "print y" makes a call to
> Y.__str__() . But Y.__str__() can be printed?? So what is 'print' exactly
> doing?

It looks at sys.stdout.encoding. If this is set, and the thing to print
is a unicode string, it converts it to the stream encoding, and prints
the result of the conversion.

Regards,
Martin



More information about the Python-list mailing list