Linux : python : clear input buffer before raw_input()
Question: I have looked at a few thread about this, but it doesn't seem to solve my
problem. I am running linux and when I use raw_input(), with a pause between
each, it will take the data that I have pressed before, here is an example :

    
    
     import time
     a = raw_input("first input")
     b = raw_input("second input")
     time.sleep(5)
     #flush junk?
     a = raw_input("third input")
     b = raw_input("fourth input")
    

if I press any keys followed by the enter during the 5 seconds, the two other
raw input will take the input. I would like to be able to flush the data and
let the user be prompted.

thank you.


Answer: Use keypress getch class of tty (linux) and msvcrt (windows) and use
sys.stdout.flush() function to flush the buffer

