PDA

View Full Version : How to make python prog to wait some time


crazyfuturamanoob
March 5th, 2008, 12:45 PM
How do I make my python program to wait some time (several seconds)?
Like this:

print & do stuff
...

wait 6 seconds

...
continue doing stuff

WW
March 5th, 2008, 12:50 PM
You can use the sleep function in the time module. E.g.

import time

print "This"
time.sleep(6)
print "and that."

crazyfuturamanoob
March 6th, 2008, 09:19 AM
Thanks. It works.

crazyfuturamanoob
July 25th, 2008, 04:18 AM
You can use the sleep function in the time module. E.g.

import time

print "This"
time.sleep(6)
print "and that."

Oh wait, how can I do that in milliseconds? If I want it to sleep for 200 milliseconds, will I type in 0.2?

kpkeerthi
July 25th, 2008, 04:49 AM
sleep(...)
sleep(seconds)

Delay execution for a given number of seconds. The argument may be
a floating point number for subsecond precision.

The Cog
July 25th, 2008, 08:01 AM
Oh wait, how can I do that in milliseconds? If I want it to sleep for 200 milliseconds, will I type in 0.2?
Yes. I guess the resolution depends on the OS though.