Nov-30-2017, 03:19 AM
ok, i had forgotten the terminology.
BTW, r'\' did not behave as i expected ... try it
BTW, r'\' did not behave as i expected ... try it
Output:Python 3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> r'foo\\'
'foo\\\\'
>>> r'foo\'
File "<stdin>", line 1
r'foo\'
^
SyntaxError: EOL while scanning string literal
>>>
i think i see what the interpreter is doing. it is doing a preliminary parse for the ending quote before it considers the raw indication, then maybe applies the escape sequence conversion on what it has collected.Output:>>> 'foo\'bar'
"foo'bar"
>>> r'foo\'bar'
"foo\\'bar"
>>>
this is that kind of behavior (quirks) that testing things reveals. escaping the quote is still done even for raw strings. but that is probably done in the source code parsing layer, anyway.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.