I have one python file named testings.py
, in this file I derive a dictionary by using web scraping of relevant data. To populate the dictionary takes a few minutes.
What I would like to do, instead of copying the whole script into my other python script named webscraper.py
, and then running the whole of both scripts in effect every time I run webscraper.py
, is instead import the dictionary from the testing.py
script into the second script webscraper.py
and then save myself those minutes everytime I run webscraper.py
.
Every so often my dictionary will be out of date, in which case I would just run testings.py
before starting webcraper.py
. Is there a way to do what I'm asking?
Another thing to note is that, at the start of testings.py
I have my_dict = {}
and it's not until the end of the script that my_dict
is fully populated. So when I import it I want to import the fully populated version of it as if the script had run fully.