Chris Angelico writes:
> 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
Marko Rauhamaa wrote:
> Peter Otten <__pete...@web.de>:
>
>> In addition to what already has been said: you can switch off output
>> buffering of stdout/stderr with
>>
>> python -u out.py
>>
>> or by setting the PYTHONUNBUFFERED environment variable.
>
> Very often such externalities are not in
Peter Otten <__pete...@web.de>:
> In addition to what already has been said: you can switch off output
> buffering of stdout/stderr with
>
> python -u out.py
>
> or by setting the PYTHONUNBUFFERED environment variable.
Very often such externalities are not in the control of the application
develo
Steven D'Aprano wrote:
> I'm trying to read from stdin. Here I simulate a process that slowly
> outputs data to stdout:
>
> steve@runes:~$ cat out.py
> import time
>
> print "Hello..."
> time.sleep(10)
> print "World!"
> time.sleep(10)
> print "Goodbye!"
In addition to what already has been sai
On Tue, 26 Aug 2014 23:07:36 -0700, Naoki INADA wrote:
> for line in iter(sys.stdin.readline(), ''):
Thanks for that. Removing the parens after readline seems to do the trick.
--
Steven
--
https://mail.python.org/mailman/listinfo/python-list
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 pare
On Wed, 27 Aug 2014 08:29:20 +0300, Marko Rauhamaa wrote:
> Steven D'Aprano :
>
>> When I pipe one to the other, I expect each line to be printed as they
>> arrive, but instead they all queue up and happen at once:
>
> Try flushing after each print.
Doesn't help.
Here is an update that may mak
I recommend Python 3.
On Python 2, iterating lines without buffering is slow, tricky and ugly.
for line in iter(sys.stdin.readline(), ''):
print line
—
Sent from Mailbox
On Wed, Aug 27, 2014 at 3:03 PM, Chris Angelico wrote:
> On Wed, Aug 27, 2014 at 3:19 PM, Steven D'Aprano wrote:
>>
On Wed, Aug 27, 2014 at 3:19 PM, Steven D'Aprano wrote:
> When I pipe one to the other, I expect each line to be printed as they
> arrive, but instead they all queue up and happen at once:
You're seeing two different problems here. One is the flushing of
stdout in out.py, as Marko mentioned, but
Marko Rauhamaa :
> Try flushing after each print.
http://stackoverflow.com/questions/230751/how-to-flush-ou
tput-of-python-print>
Since Python 3.3, there is no need to use sys.stdout.flush():
print(*objects, sep=' ', end='\n', file=sys.stdout, flush=False)
Marko
--
https://mail.
Steven D'Aprano :
> When I pipe one to the other, I expect each line to be printed as they
> arrive, but instead they all queue up and happen at once:
Try flushing after each print.
When sys.stdout is a pipe, flushing happens only when the internal
buffer fills up.
Marko
--
https://mail.pytho
11 matches
Mail list logo