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()

    proc Elaborate() :

    I'll apreciate any help!
    Sam, Oct 28, 2004
    1. Advertisements

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

  3. Sam

    Sam Guest

    Now I try.

    Sam, Oct 28, 2004
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.