Q:

Autorun python script from python

I wrote a python script that downloads a random picture from APOD. I want to be able to specify the update frequency in python and have python automatically run the script. So the program would look something like this:
//first setup
print "how often should the background change in hours?"
updatefrequency = input()
schedule_autorun(updatefrequency)
//run each time
runprogram()

I've seen that people have used the windows task scheduler to auto run the program, but I would like to set it from python. I am running python 2.7 on Windows 7

A:

How about the time module?
import time
timeinseconds = 100000
while(1):
    time.sleep(timeinseconds)
    runProgram()

If the time it takes to run the program exceeds your wait time, you can also call it as a separate process.
from subprocess import call
call(['python','runProgram.py'])

or subprocess.Popen

