CLEAR INPUT BUFFER

Discussion in 'Python' started by Sam, Oct 28, 2004.

  1. Sam

    Sam Guest

    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
    Sam, Oct 28, 2004
    #1
    1. Advertising

  2. 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.
    Istvan Albert, Oct 28, 2004
    #2
    1. Advertising

  3. Sam

    Sam Guest

    "Istvan Albert" <> wrote in message
    news:...
    > 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
    Sam, Oct 28, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Emmanuel Freund

    clear the java buffer

    Emmanuel Freund, Nov 24, 2004, in forum: Java
    Replies:
    5
    Views:
    830
    Emmanuel Freund
    Nov 24, 2004
  2. Mark Warren
    Replies:
    3
    Views:
    16,523
    Sam Holden
    Jul 23, 2003
  3. voidstar
    Replies:
    3
    Views:
    10,070
    Mark R Rivet
    Jul 27, 2004
  4. David

    Response.Clear() doesn't clear

    David, Jan 31, 2008, in forum: ASP .Net
    Replies:
    2
    Views:
    1,001
    Mark Fitzpatrick
    Jan 31, 2008
  5. InvalidLastName

    Unrecognized element 'add' after <clear></clear>

    InvalidLastName, Feb 26, 2007, in forum: ASP .Net Web Services
    Replies:
    3
    Views:
    933
    Steven Cheng[MSFT]
    Mar 6, 2007
Loading...

Share This Page