468,733 Members | 1,195 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,733 developers. It's quick & easy.

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 9982
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
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.