How to timeout when waiting for raw_input from user ?

northof40 shearichard at gmail.com
Fri Dec 4 18:52:52 EST 2009


Hi - I'm writing a *very* simple program for my kids. It asks the user
to give it the answer to a maths question and says "right" or "wrong"

They now want a timed version where they would only get so long to
respond to the question.

I'm thinking of some logic where a raw_input call is executed and then
if more than X seconds elapses before the prompt is replied to the
process writes a message "Sorry too slow" (or similar).

I can't see the wood for the trees here - what's the best way to do
this given the rather simple environment it's needed within.

Regards

richard.




More information about the Python-list mailing list