[Tutor] how do i pause a script ?

Brian van den Broek bvande at po-box.mcgill.ca
Wed Jun 22 00:27:12 CEST 2005


nephish said unto the world upon 21/06/2005 20:17:
> Hey all,
> how do i pause a script. like
> print 'something'
> pause a half second
> print 'something else'
> 
> any takers?
> 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
> 
> 

Hi,

import time

for i in range(5):
     time.sleep(i)
     print time.asctime()

when run produces:

 >>> Tue Jun 21 18:23:00 2005
Tue Jun 21 18:23:01 2005
Tue Jun 21 18:23:03 2005
Tue Jun 21 18:23:06 2005
Tue Jun 21 18:23:10 2005


6.11 time -- Time access and conversions
"sleep(secs)
     Suspend execution for the given number of seconds. The argument 
may be a floating point number to indicate a more precise sleep time. 
The actual suspension time may be less than that requested because any 
caught signal will terminate the sleep() following execution of that 
signal's catching routine. Also, the suspension time may be longer 
than requested by an arbitrary amount because of the scheduling of 
other activity in the system."
http://docs.python.org/lib/module-time.html

Best,

Brian vdB



More information about the Tutor mailing list