I have a Python program that navigates me to a website with a function that I have defined as nav(a, b), and on this site I will be downloading some pyfits data for use on another script. This site has a different pyfits file for every set of (a,b) in a catalog I have.
I was wondering if I could iterate through this catalog using a for
loop, and each time the nav(a, b) function is used, tell python to pause while I download the file, then resume again when I tell it to. I've done something like this in IDL before, but don’t know how with Python.
Otherwise I guess I'm stuck running the program 200 times, replacing the (a, b) values each time, which will take for ever.
If you've got a Python program and you want to make it wait, you can use a simple function like this one: time. sleep(x) where x is the number of seconds that you want your program to wait.
There are two ways to do this: Use time.sleep() as before. Use Event.wait() from the threading module.
Python sleep() function will pause Python code or delay the execution of program for the number of seconds given as input to sleep(). The sleep() function is part of the Python time module. You can make use of Python sleep function when you want to temporarily halt the execution of your code.
If you want to wait for a manual signal to continue, wait for the user to press Enter:
Python 2:
raw_input("Press Enter to continue...")
Python 3:
input("Press Enter to continue...")
If you can download the file in the python code, do that instead of doing the manual task for each of the files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With