Saad Javed wrote:
> import time
>
> running = True
> while running:
> print 'yes'
> time.sleep(10)
>
> This will print 'yes' after every 10s. I want to print 'yes' for 10s, then
> quit.
Then combine the two techniques, the busy waiting loop with sleeping for a
shorter amount of time:
On 25/11/12 22:01, Saad Javed wrote:
time.sleep(30) will pause the program for 30s. I want to the run the
program for 30s.
Your first email did not make that clear. Please take more care to
explain your question.
stop = time.time() + 30
while time.time() < stop:
do_something_useful()
pr
import time
running = True
while running:
print 'yes'
time.sleep(10)
This will print 'yes' after every 10s. I want to print 'yes' for 10s, then
quit.
Saad
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
ht
time.sleep(30) will pause the program for 30s. I want to the run the
program for 30s.
Saad
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
On 25/11/12 19:50, Saad Javed wrote:
import time
s = time.time() + 30
running = True
while running:
if time.time() == s:
print 'yes'
running = False
This stops the loop after 30s but the program uses about 12% cpu. What
would be a more efficient way to do this? (p.s. i'm on python 2.7.3)
im
import time
s = time.time() + 30
running = True
while running:
if time.time() == s:
print 'yes'
running = False
This stops the loop after 30s but the program uses about 12% cpu. What
would be a more efficient way to do this? (p.s. i'm on python 2.7.3)
Saad
___