title: Python question about write() and truncate()
body: <p>I am in Terminal on mac and I am learning how to open, close, read, delete files.</p>
  
  <p>When I set </p>
  
  <pre><code>f = open("sample.txt", 'w')
  </code></pre>
  
  <p>and then hit <code>f.truncate()</code> the contents delete.</p>
  
  <p>However, when I do <code>f.write()</code> it does not update in the text file. It only updates after I do <code>f.truncate()</code>. </p>
  
  <p>I was wondering why this happens (I thought <code>f.truncate()</code> was supposed to delete the text!)? Why doesn't the text editor update automatically when I type in <code>f.write()</code> ?</p>