[issue31136] raw strings cannot end with a backslash character r'\'

2019-02-20 Thread Graham Wideman
Graham Wideman added the comment: Demonstration: print("x" + r' \' ' + "x") produces x \' x Where is this behavior _ever_ useful? Or if there is some use case for this, how frequent is it compared to the frequency of users expecting either that backslash does nothing special, or that it

[issue31136] raw strings cannot end with a backslash character r'\'

2019-02-20 Thread Graham Wideman
Graham Wideman 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

[issue31136] raw strings cannot end with a backslash character r'\'

2017-08-08 Thread Gregory P. Smith
Gregory P. Smith added the comment: If i could stop thinking of r as meaning "raw" as we document it and instead "regular expression literal" I wouldn't make this mistake. :) Thanks everyone! -- ___ Python tracker

[issue31136] raw strings cannot end with a backslash character r'\'

2017-08-08 Thread R. David Murray
R. David Murray added the comment: In fact, this ia a FAQ: https://docs.python.org/3/faq/design.html#why-can-t-raw-strings-r-strings-end-with-a-backslash -- nosy: +r.david.murray ___ Python tracker

[issue31136] raw strings cannot end with a backslash character r'\'

2017-08-07 Thread Tim Peters
Tim Peters added the comment: Yes, I'm closing as not-a-bug. It's been this way (and documented) forever. More specifically, as the docs say, a raw string can't end with an _odd_ number of backslashes: """ String quotes can be escaped with a backslash, but the backslash remains in the

[issue31136] raw strings cannot end with a backslash character r'\'

2017-08-07 Thread Gregory P. Smith
Gregory P. Smith added the comment: This may well be a "not a bug" resolution to preserve existing semantics that weren't what I expected. -- ___ Python tracker

[issue31136] raw strings cannot end with a backslash character r'\'

2017-08-07 Thread Martin Panter
Martin Panter added the comment: What would your proposal do where an embedded backslash is currently valid? >>> print(r'Backslash apostrophe: \'.') Backslash apostrophe: \'. >>> r'\' # Comment or string?' "\\' # Comment or string?" -- nosy: +martin.panter

[issue31136] raw strings cannot end with a backslash character r'\'

2017-08-07 Thread STINNER Victor
STINNER Victor added the comment: Workaround working on all Python versions, string concatenation made by the compiler: r"" "...". >>> print(r"a\n" "\\") a\n\ -- nosy: +haypo ___ Python tracker

[issue31136] raw strings cannot end with a backslash character r'\'

2017-08-07 Thread Eric V. Smith
Changes by Eric V. Smith : -- nosy: +eric.smith ___ Python tracker ___ ___

[issue31136] raw strings cannot end with a backslash character r'\'

2017-08-07 Thread Gregory P. Smith
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