title: Saving Dictionary as Python Script
body: <p>I'm somewhat new to Python.  I have a very long process that calculates a dictionary where keys are tuples on floats, and values are lists of floats.  I want to run the same script multiple times but only comput the dictionary once.  I would also like to be able to access the dictionary on other scrits.  My idea was to compute the dictionary and write it to another .py file that I could just import in any script I want.  I've found a lot of stuff on writing data to a txt file, and reading a txt file, but is there a quick way of writing directly to another .py file?  That is, I would like something like:</p>
  <pre><code>def Complicated_Process():
  
        Compute some dictionary D
        write D to file.py
  </code></pre>
  <pre><code>import file.py
  
  D = the dictionary in file.py
  </code></pre>