title: How to prevent automatic escaping of special characters in Python
body: <p>I'm writing a Python script that accepts file paths as strings, parses them, appends a command name, and builds a list, which is then passed to <code>subprocess.Popen()</code> for execution.  This script is to handle both Unix and Windows file paths, and ultimately should run on both systems.  </p>
  
  <p>When I run this under Unix, if I give a Windows path that inadvertently contains an escape character (e.g. <code>\Users\Administrator\bin</code>), Python will interpret the embedded <code>\b</code> as the backspace character.  I want to prevent that from happening.</p>
  
  <p>As far as I know, there's no function or method to denote a string variable as a raw string.  The <code>'r'</code> modifier only works for string constants.</p>
  
  <p>So far, the closest I've been able to get is this:</p>
  
  <pre><code>winpath = "C:\Users\Administrator\bin" 
  winpath = winpath.replace('\b','\\b')
  winpathlist = winpath.split('\\') 
  </code></pre>
  
  <p>At this point, winpathlist should contain <code>['C:','Users','Administrator','bin']</code>, not <code>['C','Users','Administrator\x08in']</code>.  </p>
  
  <p>I can add additional calls to <code>winpath.replace()</code> to handle the other escapes I might get -- <code>\a</code>, <code>\f</code>, <code>\n</code>, <code>\r</code>, <code>\t</code>, <code>\v</code> -- but not <code>\x</code>.</p>
  
  <p>Is there a more pythonic way to do this?</p>