Hi Garfield,

Backslash is always an escape character, even in the raw string. The r prefix makes the original backslash and following character appear in the char sequence (instead of being interpreted).

Refer to the following:
https://stackoverflow.com/questions/647769/why-cant-pythons-raw-string-literals-end-with-a-single-backslash
https://docs.python.org/3/reference/lexical_analysis.html#string-and-bytes-literals

Regards,
Maciej

pon., 22 sie 2022 o 16:10 <garfield@garfieldhudson.com> napisał(a):

Hi guys,

 

Is this a bug with raw strings?  If the last character of the string is a backslash, I get an unterminated string error.  If I add another character, the error goes away.   I thought that the r prefix rendered everything within the quotes as literals.

 

Thanks,

Garfield.

_______________________________________________
docs mailing list -- docs@python.org
To unsubscribe send an email to docs-leave@python.org
https://mail.python.org/mailman3/lists/docs.python.org/
Member address: maciej.olko@gmail.com