[Tutor] Still Can't Find Timed While Loops

Scottie Hotchkiss shotchkiss at signalmtnlodge.com
Fri Dec 7 20:36:20 CET 2007


Disclaimer: I can't test this while I'm at work, but using

"while 1:"

instead of

"while time.time() - start < 30.0"

would be better.

In the former case if you press enter after time has run out, it won't 
print the time, in the latter you could potentially make a correct 
answer after time has  run out.

Example: At 29.0 you answer
raw_input awaits and you wait 5 minutes, then answer.
It will still run the print statement. The loop started and it doesn't 
matter how long you wait, because it won't evaluate that until the loop 
starts again.

But it may alright depending on what you are trying to accomplish.

Just my 2 cents,
S Hotchkiss

Tutor Lurker


More information about the Tutor mailing list