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


Groups > comp.lang.python > #74978

Re: Unicode, stdout, and stderr

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.news.ox.ac.uk!news.ox.ac.uk!news.stack.nl!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'win32': 0.03; 'interpreter': 0.05; 'output': 0.05; 'important,': 0.07; 'sys': 0.07; 'input,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'statements': 0.09; 'worked.': 0.09; 'python': 0.11; 'wrote': 0.14; 'windows': 0.15; 'errors:': 0.16; 'fails.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'skip:n 50': 0.16; 'stderr': 0.16; 'stdout': 0.16; 'subject:Unicode': 0.16; 'sys.stderr': 0.16; 'sys.stdout': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'module': 0.19; 'seems': 0.21; 'code,': 0.22; 'input': 0.22; 'import': 0.22; '(in': 0.22; 'error': 0.23; 'unicode': 0.24; 'source': 0.25; 'logging': 0.26; 'this:': 0.26; 'header:X-Complaints-To:1': 0.27; 'skip:( 20': 0.30; 'file': 0.32; 'run': 0.32; '(including': 0.33; 'could': 0.34; 'problem.': 0.35; 'case,': 0.35; 'objects': 0.35; 'test': 0.35; 'but': 0.35; 'there': 0.35; '+0200,': 0.36; 'server': 0.38; 'displays': 0.38; 'mine': 0.38; 'writes': 0.38; 'to:addr:python-list': 0.38; 'expect': 0.39; 'explain': 0.39; 'does': 0.39; 'to:addr:python.org': 0.39; 'changed': 0.39; 'received:org': 0.40; 'expression': 0.60; 'more': 0.64; 'between': 0.67; 'frank': 0.68; 'led': 0.72; 'jul': 0.74; '2014,': 0.84; 'fail.': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From "Frank Millman" <frank@chagford.com>
Subject Re: Unicode, stdout, and stderr
Date Tue, 22 Jul 2014 09:15:39 +0200
References <mailman.12161.1406009902.18130.python-list@python.org> <53ce0b96$0$29897$c3e8da3$5496439d@news.astraweb.com>
X-Gmane-NNTP-Posting-Host 197.87.184.209
X-MSMail-Priority Normal
X-Newsreader Microsoft Outlook Express 6.00.3790.4657
X-RFC2646 Format=Flowed; Original
X-MimeOLE Produced By Microsoft MimeOLE V6.00.3790.4913
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.12166.1406013356.18130.python-list@python.org> (permalink)
Lines 63
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1406013356 news.xs4all.nl 2886 [2001:888:2000:d::a6]:51734
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:74978

Show key headers only | View raw


"Steven D'Aprano" <steve@pearwood.info> wrote in message 
news:53ce0b96$0$29897$c3e8da3$5496439d@news.astraweb.com...
> On Tue, 22 Jul 2014 08:18:08 +0200, 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'
>
>
> What makes you think it uses stderr? To the best of my knowledge, it uses
> stdout.
>

This is from the docs on sys.stdxxx

sys.stdin
sys.stdout
sys.stderr

File objects used by the interpreter for standard input, output and errors:
  - stdin is used for all interactive input (including calls to input());
  - stdout is used for the output of print() and expression statements and 
for the prompts of input();
  - The interpreter's own prompts and its error messages go to stderr.

>
>> It seems that there is a difference between writing to stdout and
>> writing to stderr.
>
> I would be surprised if that were the case, but I don't have a Windows
> box to test it. Try this:
>
>
> import sys
> print(x, file=sys.stderr)  # I expect this will fail

It does not fail.

> print(repr(x), file=sys.stdout)  # I expect this will succeed
>

It fails.

The clue that led me to stderr is that the logging module displays unicode 
strings to the console without a problem. I delved into the source code, and 
found that it writes to stderr. When I changed mine to stderr, it also 
worked.

Frank


Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Unicode, stdout, and stderr "Frank Millman" <frank@chagford.com> - 2014-07-22 08:18 +0200
  Re: Unicode, stdout, and stderr wxjmfauth@gmail.com - 2014-07-21 23:54 -0700
  Re: Unicode, stdout, and stderr Steven D'Aprano <steve@pearwood.info> - 2014-07-22 06:58 +0000
    Re: Unicode, stdout, and stderr "Frank Millman" <frank@chagford.com> - 2014-07-22 09:15 +0200
    Re: Unicode, stdout, and stderr Lele Gaifax <lele@metapensiero.it> - 2014-07-22 09:36 +0200
    Re: Unicode, stdout, and stderr Akira Li <4kir4.1i@gmail.com> - 2014-07-23 05:01 +0400
      Re: Unicode, stdout, and stderr wxjmfauth@gmail.com - 2014-07-23 00:35 -0700
  Re: Unicode, stdout, and stderr wxjmfauth@gmail.com - 2014-07-22 00:07 -0700

csiph-web