Graham Wideman <initcont...@grahamwideman.com> added the comment:

Let us be clear here that this is NOT a case where the backslash escapes the 
subsequent quote. If it WAS such a case, then the sequence \' would leave only 
the quote in the output string. But it doesn't; it leaves the complete 
2-character \' in the output string.
So essentially this is a case of the character sequence \' being given a 
special status that causes that character pair to have a special meaning in 
preference to the meaning of the individual characters.
So this IS a bug -- it may be "as designed", but that produces the bug in the 
name of this feature, "raw string", which is patently misleading and in 
violation of the principle of least surprise. This is a feature (as the FAQ 
explains) provided explicitly for developers of regular expression parsers. So 
at best, these r-strings should be called "regex-oriented" string literals, 
which can be used elsewhere, at risk of knowing this gotcha.

----------
nosy: +gwideman

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue31136>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to