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
messages: 299883
nosy: gregory.p.smith
priority: normal
severity: normal
status: open
title: raw strings cannot end with a backslash character r'\'
versions: Python 3.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://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