How to timeout when waiting for raw_input from user ?

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


On Dec 5, 12:52 pm, northof40 <shearich... at gmail.com> wrote:
> 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.

Sorry I should said that based upon other answers I've seen to similar
questions this needs to run on a windows machine (other answers
suggest this is more difficult than running on *nix)




More information about the Python-list mailing list