Timer

Derek Fountain nomail at hursley.ibm.com
Mon Oct 27 08:04:37 EST 2003


Dave Harrison wrote:

>> > > Does Python have a timer mechanism? i.e. an "after 500 milliseconds,
>> > > run this bit of code" sort of thing?
> 
> why not just use the time.sleep() function ?

Because that stops the thread. I want things to continue, and then be
interrupted in order to execute a bit of code. Tcl has the 'after' command:

after 5000 { set disabled 0 }

The script carries on, and after 5 seconds whatever is being done gets
interrupted in order to run a bit of script - in this case set a variable
turning off a disablement of some sort. This makes it trivial to implement
"disable this feature for 5 seconds" kinds of logic.

I can't find anything like that in Python.




More information about the Python-list mailing list