[New-bugs-announce] [issue31136] raw strings cannot end with a backslash character r'\'
Gregory P. Smith
report at bugs.python.org
Mon Aug 7 20:50:49 EDT 2017
New submission from Gregory P. Smith:
A raw string literal cannot end in a backslash. There is no friendly way to write a string that ends in a backslash character.
In particular I want to put the following into a Python string: \\?\
'\\\\?\\' works but is escaping hell so I wanted to suggest to the author to use r'\\?\' but that leads to:
SyntaxError: EOL while scanning string literal
Tested in a random 3.7.0a0 build as well as older 2.7 and 3.x stable versions.
r'\' is the easiest way to reproduce this. (which could be written using the same number of bytes as '\\'... the use case above where a string containing a lot of \s that also ends in a \ is where it matters more from a code beauty point of view)
Can we update the parser to allow this?
components: Interpreter Core
title: raw strings cannot end with a backslash character r'\'
versions: Python 3.7
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce