Flush stdin

Cameron Simpson cs at zip.com.au
Sat Oct 18 23:01:11 CEST 2014


On 18Oct2014 17:55, Nobody <nobody at nowhere.invalid> wrote:
>On Fri, 17 Oct 2014 12:38:54 +0100, Empty Account wrote:
>> I am using netcat to listen to a port and python to read stdin and print
>> to the console.
>>
>> nc -l 2003 | python print_metrics.py
>>
>> sys.stdin.flush() doesn’t seem to flush stdin,
>
>You can't "flush" an input stream.

Sure you can. Most streams are read through an API which buffers. That buffer 
can be discarded.

I'm not sure it is what the OP needs, but it is not a nonsensical idea.

Cheers,
Cameron Simpson <cs at zip.com.au>

I've seen things you people wouldn't believe.  Attack ships on fire off the
shoulder of Orion. I've watched C-beams glitter in the dark near the
Tannhauser Gate.  All these memories will be lost in time, like tears in rain.
         - Roy Baty, _Blade Runner_



More information about the Python-list mailing list