title: f.write vs print >> f
body: <p>There are at least two ways to write to a file in python:</p>
  
  <pre><code>f = open(file, 'w')
  f.write(string)
  </code></pre>
  
  <p>or</p>
  
  <pre><code>f = open(file, 'w')
  print &gt;&gt; f, string     # in python 2
  print(string, file=f)  # in python 3
  </code></pre>
  
  <p>Is there a difference between the two? Or is any one more Pythonic? I'm trying to write a bunch of HTML to file so I need a bunch of write/print statements through my file(but I don't need a templating engine).</p>