title: In python, can I redirect the output of print function to stderr?
body: <p>There're lots of <code>print</code> function (<code>python 2.7</code>) in my program. Is there any way I can add a few lines then all the output can be redirected to <code>stderr</code>? What I want is python codes but not linux pipeline.</p>
  
  <p>For example, my program is like:</p>
  
  <pre><code>print 'hello world'
  </code></pre>
  
  <p>I would like to add some codes like:</p>
  
  <pre><code>redirect_output_to_stderr()
  print 'hello world'
  </code></pre>
  
  <p>Then all the output can be redirected to <code>stderr</code>.</p>
  
  <p>I know <code>print &gt;&gt; sys.stderr, 'hello world'</code> can achieve my goal, but is it any way that can prevent from modifying the existed codes?</p>