[Tutor] how do i pause a script ?

Simon Gerber nequeo at gmail.com
Wed Jun 22 11:04:43 CEST 2005


>Hey all,
>how do i pause a script. like
>print 'something'
>pause a half second
>print 'something else'
>  
>

Hi,

I think you're looking for 'sleep' in the time module.

 >>> import time
 >>> print "something"
 >>> time.sleep(1)
 >>> print "something else"

That should do what you're describing. Incidentally, 'sleep' takes a 
float, not an int. So you can use time.sleep(1.5) to pause for one and a 
half seconds, and so forth.

Hope that helps! If anyone knows a better way, feel free to correct me. 
I've only just started to learn Python myself.

-- 
"Come back to the workshop and dance cosmological models with me?"
 - Peer, "Permutation City", by Greg Egan. 

Simon Gerber
nequeo at gmail.com



More information about the Tutor mailing list