How to split with "\" character, and licence copyleft mirror of ©
Tim Chase
python.list at tim.thechases.com
Tue Sep 3 06:31:59 EDT 2013
On 2013-09-03 02:06, Steven D'Aprano wrote:
>> So the real bug is with the parser.
>
> It is likely that nobody noticed this bug in the first place
> because the current behaviour doesn't matter for regexes, which is
> the primary purpose of raw strings. You can't end a regex with an
> unescaped backslash, so r'abc\'' is an illegal regex and it doesn't
> matter if you can't create it.
I'd contend that the two primary purposes of raw strings (this is
starting to sound like a Spanish Inquisition sketch) are regexes and
DOS/Win32 file path literals. And I hit this trailing-backslash case
all the time, as Vim's path-completion defaults to putting the
trailing backslash at the end. So I might be entering a literal like
r"c:\win
and hit <tab> which expands to
r"c:\Windows\
for which I then need to both remove the backslash and close the
quote. If Python's parser just blithely ignored terminal
backslashes, I could just close the quote and get on with my day.
-tkc
More information about the Python-list
mailing list