Now I've found also an FAQ item for this exact topic in the docs:

https://docs.python.org/3/faq/design.html#why-can-t-raw-strings-r-strings-end-with-a-backslash

Wonder why it doesn't google well.

Regards,
Maciej

wt., 7 mar 2023 o 17:02 <garfield@garfieldhudson.com> napisał(a):

Thanks!

 

From: Maciek Olko <maciej.olko@gmail.com>
Sent: Monday, March 6, 2023 4:06 AM
To: garfield@garfieldhudson.com
Cc: docs@python.org
Subject: Re: [docs] Raw String Bug?

 

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:

 

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

_______________________________________________
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