Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #74984 > unrolled thread

Re: Unicode, stdout, and stderr

Started by"Frank Millman" <frank@chagford.com>
First post2014-07-22 09:41 +0200
Last post2014-07-22 09:41 +0200
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Unicode, stdout, and stderr "Frank Millman" <frank@chagford.com> - 2014-07-22 09:41 +0200

#74984 — Re: Unicode, stdout, and stderr

From"Frank Millman" <frank@chagford.com>
Date2014-07-22 09:41 +0200
SubjectRe: Unicode, stdout, and stderr
Message-ID<mailman.12172.1406015105.18130.python-list@python.org>
"Peter Otten" <__peter__@web.de> wrote in message 
news:lql3am$2q7$1@ger.gmane.org...
> Frank Millman wrote:
>
>> Hi all
>>
>> This is not important, but I would appreciate it if someone could explain
>> the following, run from cmd.exe on Windows Server 2003 -
>>
>> C:\>python
>> Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32
>> bit (In
>> tel)] on win32
>> Type "help", "copyright", "credits" or "license" for more information.
>>>>> x = '\u2119'
>>>>> x  # this uses stderr
>> '\u2119'
>
> No, both print to stdout, but just
>
>>>> x
>
> is passed to the display hook of the interactive interpreter. This applies
> repr() and  then tries to print the result. If this fails it makes another
> effort, roughly (the actual code is written in C)
>
> sys.stdout.buffer.write(repr(x).encode(
>    sys.stdout.encoding, "backslashreplace"))
>
>

Thanks, Peter. Very interesting.

Out of interest, does the same thing happen when writing to sys.stderr?

Frank


[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web