title: Quoting backslashes in Python string literals
body: <p>I have a string that contains both double-quotes and backslashes that I want to set to a variable in Python. However, whenever I try to set it, the quotes or slashes are either removed or escaped. Here's an example:</p>
  
  <pre><code>&gt;&gt;&gt; foo = 'baz "\"'
  &gt;&gt;&gt; foo
  'baz ""'
  </code></pre>
  
  <p>So instead of <code>baz "\"</code> like I want I'm getting <code>baz ""</code>. If I then try to escape the backslash, it doesn't help either:</p>
  
  <pre><code>&gt;&gt;&gt; foo = 'baz "\\"'
  &gt;&gt;&gt; foo
  'baz "\\"'
  </code></pre>
  
  <p>Which now matches what I put in but wasn't what I originally wanted. How do you get around this problem?</p>