Unicode conversion in 'print'

"Martin v. Löwis" martin at v.loewis.de
Fri Jan 14 18:19:50 CET 2005


Ricardo Bugalho wrote:
>  thanks for the information. But what I was really looking for was
> informaion on when and why Python started doing it (previously, it always
> used sys.getdefaultencoding())) and why it was done only for 'print' when
> stdout is a terminal instead of always.

It does that since 2.2, in response to many complains that you cannot
print a Unicode string in interactive mode, unless the Unicode string
contains only ASCII characters. It does that only if sys.stdout is
a real terminal, because otherwise it is not possible to determine
what the encoding of sys.stdout is.

Regards,
Martin



More information about the Python-list mailing list