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: 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 Cc: "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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 On Wed, Aug 27, 2014 at 4:37 PM, Steven D'Aprano 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