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


Groups > comp.lang.python > #77109

Re: Reading from sys.stdin reads the whole file in

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!news2.arglkargh.de!news.albasani.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'subject:file': 0.07; 'sys': 0.07; 'works.': 0.09; 'cc:addr:python-list': 0.11; 'does,': 0.16; 'fine;': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'subject:Reading': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'help.': 0.21; 'import': 0.22; 'aug': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; "doesn't": 0.30; 'message- id:@mail.gmail.com': 0.30; '(although': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'run': 0.32; 'subject:the': 0.34; 'subject:from': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'pm,': 0.38; 'to:none': 0.92
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=9k1nsATOK4hqt2G7j6FdBe6B8b9cbXSKAcw5kQ0MN1c=; b=fuJFdcu0XIcjvz03Ml/sWcBQjtCtbNebDwI673HxdEfv8nrFFK+ozj9dSZwd3KsC0v alpzKkyv1GyoAGTU9eA7VkBtMi7noTQVUXQ+dlGk9EA6GGM1NBAEJbEEVvT8wUlsm/qE hRL4Fq2WnePeWQNW5KlmGY7B5s9FZGr1Oj7ymYaGsBUuiyCNpDdlo3kddlj99DRckFnp kEJk+nrIfcmkMg/Q5r2ZEFUAQkmfLQOYwOFARijfU94Xf6R6x1/640gt4RMEnGctgZb4 uIKRrk/avsIqS+l5EpXD9xQA6MoXa8YLhDpOi4UxzNZfxztv+bqcVIRDOKWSxjU25eit T0IA==
MIME-Version 1.0
X-Received by 10.50.66.197 with SMTP id h5mr27972318igt.34.1409121929557; Tue, 26 Aug 2014 23:45:29 -0700 (PDT)
In-Reply-To <53fd7cab$0$11111$c3e8da3@news.astraweb.com>
References <53fd6a48$0$11111$c3e8da3@news.astraweb.com> <87mwaqxzyn.fsf@elektro.pacujo.net> <53fd7cab$0$11111$c3e8da3@news.astraweb.com>
Date Wed, 27 Aug 2014 16:45:29 +1000
Subject Re: Reading from sys.stdin reads the whole file in
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
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.13492.1409121937.18130.python-list@python.org> (permalink)
Lines 21
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1409121937 news.xs4all.nl 2843 [2001:888:2000:d::a6]:49321
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:77109

Show key headers only | View raw


On Wed, Aug 27, 2014 at 4:37 PM, Steven D'Aprano <steve@pearwood.info> wrote:
> On Wed, 27 Aug 2014 08:29:20 +0300, Marko Rauhamaa wrote:
>
>> Try flushing after each print.
>
> Doesn't help.

It does, but insufficiently. If slurp.py is run under Py3, it works
fine; or take Naoki's suggestion (although without the parens):

import sys
import time

for line in iter(sys.stdin.readline, ''):
        print "Time of input:", time.ctime(), line
        sys.stdin.flush()
        sys.stdout.flush()

Then it works.

ChrisA

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


Thread

Reading from sys.stdin reads the whole file in Steven D'Aprano <steve@pearwood.info> - 2014-08-27 05:19 +0000
  Re: Reading from sys.stdin reads the whole file in Marko Rauhamaa <marko@pacujo.net> - 2014-08-27 08:29 +0300
    Re: Reading from sys.stdin reads the whole file in Marko Rauhamaa <marko@pacujo.net> - 2014-08-27 08:31 +0300
    Re: Reading from sys.stdin reads the whole file in Steven D'Aprano <steve@pearwood.info> - 2014-08-27 06:37 +0000
      Re: Reading from sys.stdin reads the whole file in Chris Angelico <rosuav@gmail.com> - 2014-08-27 16:45 +1000
      Re: Reading from sys.stdin reads the whole file in Akira Li <4kir4.1i@gmail.com> - 2014-08-29 04:02 +0400
  Re: Reading from sys.stdin reads the whole file in Chris Angelico <rosuav@gmail.com> - 2014-08-27 16:02 +1000
  Re: Reading from sys.stdin reads the whole file in Peter Otten <__peter__@web.de> - 2014-08-27 09:42 +0200
    Re: Reading from sys.stdin reads the whole file in Marko Rauhamaa <marko@pacujo.net> - 2014-08-27 11:39 +0300
      Re: Reading from sys.stdin reads the whole file in Peter Otten <__peter__@web.de> - 2014-08-27 11:31 +0200

csiph-web