title: Unescaping escaped characters in a string using Python 3.2
body: <p>Say I have a string in Python 3.2 like this:</p>
  
  <pre><code>'\n'
  </code></pre>
  
  <p>When I print() it to the console, it shows as a new line, obviously.  What I want is to be able to print it literally as a backslash followed by an n.  Further, I need to do this for all escaped characters, such as \t.  So I'm looking for a function unescape() that, for the general case, would work as follows:</p>
  
  <pre><code>&gt;&gt;&gt; s = '\n\t'
  &gt;&gt;&gt; print(unescape(s)) 
  '\\n\\t'
  </code></pre>
  
  <p>Is this possible in Python without constructing a dictionary of escaped characters to their literal replacements?</p>
  
  <p>(In case anyone is interested, the reason I am doing this is because I need to pass the string to an external program on the command line.  This program understands all the standard escape sequences.)</p>