raw_input and timeout [duplicate]
This question already has an answer here: Keyboard input with timeout in Python 11 answers I want to do a raw_input('Enter something: .') . I want it to sleep for 3 seconds and if there's no input, then cancel the prompt and run the rest of the code. Then the code loops and implements the raw_input again. I also want it to break if the user inputs something like 'q'. rbp There's an easy solution that doesn't use threads (at least not explicitly): use select to know when there's something to be read from stdin: import sys from select import select timeout = 10 print "Enter something:", rlist, _