The current Python grammar doesn't allow one to output a trailing \
in a raw string:
>>> print(r'a\b\c\')
SyntaxError: EOL while scanning string literal
On the contrary, you can write Bash like this:
echo 'a\b\c\'
I understand what the doc is saying. I wouldn't feel strange if an expression '\'
fails because the backslash is escaping the quote. What I'm questioning is r'\'
: Aren't raw strings meant to be raw (which means backslashes in the string are taken literally)?
Do we have to write r'a\b\c' + '\\'
or 'a\\b\\c\\'
to make a string literal a\b\c\
in Python? I couldn't see how this is Pythonic.