title: Creating a temp directory for storing files used in calculation
body: <p>A python script downloads 2 tables from a database, does some calculations and creates a new one, and uploads it. There are intermediate files involved and to store all the files I create a folder called “temp” in the current working directory. Before the program exits it deletes temp. This doesn’t work very well because</p>
  
  <ol>
  <li>If there already is a folder named temp it will be deleted</li>
  <li>If the program crashes before the last step of deleting temp, the next time the program runs it crashes because files with the same name exist from the previous execution.</li>
  </ol>
  
  <p>I imagine this is a relatively common scenario. How is it normally handled? </p>