This explanation is from the python documentation:
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.
If raw strings treat backslashes as char literals, why does the backslash need to be escaped in the expression:
re.compile(r"'\\'")
Instead of just being able to write:
re.compile(r"'\'")
To capture a single backslash when using the re module?