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


Groups > comp.lang.python > #98353

Re: Unbuffered stderr in Python 3

Path csiph.com!au2pb.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.freenet.ag!newsfeed0.kamp.net!newsfeed.kamp.net!fu-berlin.de!uni-berlin.de!not-for-mail
From srinivas devaki <mr.eightnoteight@gmail.com>
Newsgroups comp.lang.python
Subject Re: Unbuffered stderr in Python 3
Date Fri, 6 Nov 2015 19:10:07 +0530
Lines 19
Message-ID <mailman.86.1446817280.16136.python-list@python.org> (permalink)
References <5637165b$0$1505$c3e8da3$5496439d@news.astraweb.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de V5JQvCMeEQXHq52k8MRoBwW4gVTzeE5kYsIHKB+ATXNQ==
Return-Path <mr.eightnoteight@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.05; 'sys': 0.05; 'cc:addr:python-list': 0.09; 'stderr': 0.09; 'stdout': 0.09; 'python': 0.10; 'buffering': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'to:addr:pearwood.info': 0.16; 'to:addr:steve+comp.lang.python': 0.16; "to:name:steven d'aprano": 0.16; 'wrote:': 0.16; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'cc:no real name:2**0': 0.22; 'import': 0.24; 'header:In-Reply-To:1': 0.24; 'mon,': 0.24; 'command': 0.26; 'message-id:@mail.gmail.com': 0.27; 'function': 0.28; "i'm": 0.30; 'print': 0.30; "d'aprano": 0.33; 'steven': 0.33; 'received:google.com': 0.35; 'nov': 0.35; 'received:209.85': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'turn': 0.37; 'received:209.85.213': 0.37; 'received:209': 0.38; 'well.': 0.40; 'more': 0.63; 'importantly,': 0.66; 'redefining': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=8MNIqzvs9z+jXlsreDdAEzY/RFIk9mj5dnd+iXwKMJs=; b=MjV3XfcX8HSK2HnVxF+ItBr2pIAjO9+xGPvElqMetdDfPOwrMZ/sH+Nmwk4cj1/jV3 JRSyoH6KC1zYKjnKa2DXvlq8Vf3H614H3p7Ut1KPrB0vUMmGwj1jSFu5r68+W7REf87+ N1uTiGEQ90wq+BSs3T4LYorbhBhTKKp5/tjDMPmscyomAQSOPF2R21u4CZq0FpZHozLi xvTs8vYBX4byFGkxpSmSiQjltR0ZHsL+L4jWh2qXTAOJLOTt/WgZmxEvTNNmMnAeDBEy gYm32iCUk4CDemrOGWWZRNouLoAKfv5j+OqrssKKrqFv0cs4g0XrNqIdlLB4aoX3+O9f GC3Q==
X-Received by 10.50.138.70 with SMTP id qo6mr351503igb.41.1446817247655; Fri, 06 Nov 2015 05:40:47 -0800 (PST)
In-Reply-To <5637165b$0$1505$c3e8da3$5496439d@news.astraweb.com>
X-Mailman-Approved-At Fri, 06 Nov 2015 08:41:18 -0500
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
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>
Xref csiph.com comp.lang.python:98353

Show key headers only | View raw


On Mon, Nov 2, 2015 at 1:22 PM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
>
> So how come Python 3 has line buffered stderr? And more importantly, how can
> I turn buffering off?
>
> I don't want to use the -u unbuffered command line switch, because that
> effects stdout as well. I'm happy for stdout to remain buffered.
>
you can simply turn buffering off for stderr by redefining the print
function or declaring a new print function like


from functools import partial
print = partial(print, flush=True)
# or
from functools import partial
import sys
printerr = partial(print, flush=True, file=sys.stderr)

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


Thread

Unbuffered stderr in Python 3 Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-11-02 18:52 +1100
  Re: Unbuffered stderr in Python 3 Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2015-11-02 11:48 +0100
  Re: Unbuffered stderr in Python 3 Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2015-11-02 11:54 +0100
  Re: Unbuffered stderr in Python 3 Nobody <nobody@nowhere.invalid> - 2015-11-03 07:10 +0000
    Re: Unbuffered stderr in Python 3 Random832 <random832@fastmail.com> - 2015-11-03 10:00 -0500
    Re: Unbuffered stderr in Python 3 Chris Angelico <rosuav@gmail.com> - 2015-11-04 02:42 +1100
    Re: Unbuffered stderr in Python 3 Terry Reedy <tjreedy@udel.edu> - 2015-11-03 17:25 -0500
      Re: Unbuffered stderr in Python 3 Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-11-04 14:18 +1100
        Re: Unbuffered stderr in Python 3 Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2015-11-04 09:19 +0100
          Re: Unbuffered stderr in Python 3 Steven D'Aprano <steve@pearwood.info> - 2015-11-04 21:24 +1100
            Re: Unbuffered stderr in Python 3 Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2015-11-04 11:43 +0100
            Re: Unbuffered stderr in Python 3 Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2015-11-04 12:49 +0100
            Re: Unbuffered stderr in Python 3 Random832 <random832@fastmail.com> - 2015-11-04 08:43 -0500
        Re: Unbuffered stderr in Python 3 Terry Reedy <tjreedy@udel.edu> - 2015-11-04 18:00 -0500
  Re: Unbuffered stderr in Python 3 srinivas devaki <mr.eightnoteight@gmail.com> - 2015-11-06 19:10 +0530

csiph-web