title: writing Python shell output to file
body: <p>Very simple question. I am using the IDLE Python shell to run my Python scripts. I use the following type of structure</p>
  
  <pre><code>import sys
  sys.argv = ['','fileinp']
  execfile('mypythonscript.py')
  </code></pre>
  
  <p>Is there a simple way of outputting the results to a file? Something like</p>
  
  <pre><code>execfile('mypythonscript.py') &gt; 'output.dat'
  </code></pre>
  
  <p>Thanks</p>