title: Python: Why do raw strings require backslash to be escaped?
body: <p>This explanation is from the python documentation:</p>
  
  <blockquote>
    <p>Both string and bytes literals may optionally be prefixed with a letter 'r' or 'R'; such strings are called raw strings and treat backslashes as literal characters. As a result, in string literals, '\U' and '\u' escapes in raw strings are not treated specially. Given that Python 2.x’s raw unicode literals behave differently than Python 3.x’s the 'ur' syntax is not supported.</p>
  </blockquote>
  
  <p>If raw strings treat backslashes as char literals, why does the backslash need to be escaped in the expression:</p>
  
  <pre><code>re.compile(r"'\\'")
  </code></pre>
  
  <p>Instead of just being able to write:</p>
  
  <pre><code>re.compile(r"'\'")
  </code></pre>
  
  <p>To capture a single backslash when using the re module?</p>