[Tutor] Primitive Chess Clock Program Question

Steven D'Aprano steve at pearwood.info
Tue Jan 3 22:28:33 CET 2012

Homme, James wrote:
> Hi,
> So far, I know about raw_input as a way to get something from the keyboard into my program. My question is this. Let's say I am trying to subtract time from a value as though someone is thinking and they want to type in a move. If my program prints a prompt to the screen, while the person is thinking, is it still running, or is it asleep?

raw_input blocks for as long as it takes for the user to type something and 
press Enter. If they take an hour, raw_input will wait an hour.

I assume you want to display something like this:

Enter your next move: 0:30

where the "0:30" is the time remaining, and is constantly updating. When it 
hits zero, the function returns whether the user has typed anything or not.

Oooh, this is a cunning problem! I like it. But I have no idea how to solve 
it. I'm going to have to do some research, in my Copious Spare Time.


More information about the Tutor mailing list