title: How to delete only the content of file in python
body: <p>I have a temporary file with some content and a python script generating some output to this file. I want this to repeat N times, so I need to reuse that file (actually array of files). I'm deleting the whole content, so the temp file will be empty in the next cycle. For deleting content I use this code:</p>
  
  <pre><code>def deleteContent(pfile):
  
      pfile.seek(0)
      pfile.truncate()
      pfile.seek(0) # I believe this seek is redundant
  
      return pfile
  
  tempFile=deleteContent(tempFile)
  </code></pre>
  
  <p>My question is: Is there any other (better, shorter or safer) way to delete the whole content without actually deleting the temp file from disk?</p>
  
  <p>Something like <code>tempFile.truncateAll()</code>?</p>