r"\"" ??? (was A simple single line, triple-quoted comment)

Rustom Mody rustompmody at gmail.com
Fri Apr 3 14:52:17 CEST 2015


On Friday, April 3, 2015 at 12:43:32 PM UTC+5:30, Marko Rauhamaa wrote:
>  3. Arguing about definitions is silly. Is 0 a natural number? Is 1 a
>     prime number?

Speaking about silliness of definitions, I was knocked out in class by this today:

>>> r"\""
'\\"'

Seeing the docs
https://docs.python.org/3.4/reference/lexical_analysis.html#string-and-bytes-literals
it talks of this explicitly

But I still find it strange -- I would have expected this kind of error behavior:

>>> "A string" "another incomplete
SyntaxError: EOL while scanning string literal
>>> 



More information about the Python-list mailing list