In python, I have a function that returns a list of recent links (to folders) on a website. I also have another function that downloads the latest files from these folders. I plan to run this script every day. I have a global list with links to folders that the download function accesses every time it is executed for the last folders. I want to update this global list every five days and keep it for the next 5 days. I run the code until it is updated.
This is something like this:
list = ["link1", "link2",...] def update(): #code to update list return list def download(list): #code to download from links
So I want the update function to run every 5 days (I know how to do this) and the download function to work every day. So, how can I save the list returned from update () static as a global list until it is updated again?
EDIT: Let me clarify:
I run this on Monday:
list = ["link1", "link2"] def update(): #code to update list return list #--> list = ["link1", "link2", "link3"] def download(list): #code to download from links
this worked fine, the list was updated and used in download ().
I run this on Tuesday:
list = ["link1", "link2"] #update() won't run today, only runs every 5 days def update(): #code to update list return list #--> list = ["link1", "link2", "link3"] def download(list): #code to download from links
I restarted my code, but now link3 has not been listed since Monday. How to keep link3 link in the list for the next 5 days until I refresh the list again?
thanks
source share