title: How do I print colored output to the terminal in Python?
body: <p>Is there a Python equivalent of Perl's</p>
  <pre><code>print color 'red';
  print &lt;something&gt;;
  print color 'reset';
  </code></pre>
  <p>available?</p>
  <p>I am using this approach:</p>
  <pre><code>&quot;\x1b[1;%dm&quot; % (&lt;color code&gt;) + &quot;ERROR: log file does not exist&quot; + &quot;\x1b[0m&quot;
  </code></pre>
  <p>what I want is I should be able to set color for all print messages like,</p>
  <pre><code>print color 'red'
  function_print_something(&lt;some message&gt;)
  print color 'reset'
  </code></pre>
  <p>Here 'function_print_something' is my python function which will print some formatted log messages on to the screen.</p>