471,087 Members | 943 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,087 software developers and data experts.

CLEAR INPUT BUFFER

Sam
Good day!

I have a problem with Python and the input buffer.
My application must read a barcode from PS2 and then
process it.
The problem is: i have to discard all
characters inserted in buffer while Elaborate(data)
is running.
I tried to clear the buffer using sys.stdin.flush() but
it seem not work.

proc Principale() :
while True
# sys.stdin.flush()
data = sys.stdin.readline()
Elaborate(data)
proc Elaborate() :
sleep(5)
I'll apreciate any help!
Thanks
Jul 18 '05 #1
2 10746
Sam wrote:
I tried to clear the buffer using sys.stdin.flush() but
it seem not work.


In general you can't flush the standard input,
it is one of those undefined behaviors in C.

To read the input until an end-of-file is reached
use read() instead of readline().

Istvan.

Jul 18 '05 #2
Sam

"Istvan Albert" <ia*****@mailblocks.com> wrote in message
news:A5********************@giganews.com...
In general you can't flush the standard input,
it is one of those undefined behaviors in C.

To read the input until an end-of-file is reached
use read() instead of readline().


Now I try.
Thanks.

Bye
Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

19 posts views Thread by Dave | last post: by
3 posts views Thread by voidstar | last post: by
3 posts views Thread by Kyle Kolander | last post: by
3 posts views Thread by - Steve - | last post: by
5 posts views Thread by nx-2000 | last post: by
48 posts views Thread by Michel Rouzic | last post: by
12 posts views Thread by Tarique | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.