Kyle Stanley writes:

 > The behavior is the same on Python 3.8.2:
 > 
 > Python 3.8.2 (default, Feb 26 2020, 22:21:03)
 > [GCC 9.2.1 20200130] on linux
 > Type "help", "copyright", "credits" or "license" for more information.
 > >>> r'x\'y'
 > "x\\'y"

This looks like a defect to me.  The "'" *is* being quoted.  I.e.,
there is no syntax error, like this:

    >>> 'x'y'
      File "<stdin>", line 1
        'x'y'
           ^
    SyntaxError: invalid syntax

but the quoting character "\" is not being removed.

 > > On 22/02/2020 06:26, Steven D'Aprano wrote:

 > > > Raw strings aren't quite fully raw, which is why you can't use raw
 > > > strings for Windows paths:
 > > >
 > > >      path = r'somewhere\some\folder\'
 > > >
 > > > doesn't work. The reason is that "raw" (semi-cooked?) strings are
 > > > s/are/were/ intended for regexes[.]

With all due respect to Steve d'A, I think that reason is inaccurate
(at least in MacPorts' Python 3.8.2).  I get

    >>> path = r'somewhere\some\folder\'
      File "<stdin>", line 1
        path = r'somewhere\some\folder\'
                                       ^
    SyntaxError: EOL while scanning string literal

The reason for that, I believe, is that the rightmost "'" is quoted,
and there is no "'" terminating the string literal.

Note: I'm just spitballing based on behavior, I haven't looked at the
code (sorry, I don't know that code and don't have time to study it).

Steve
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/LFOIN5UBGZV2WFS3BTIMQ4NWL6DXQBTD/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to