12.08.19 22:41, Glenn Linderman пише:
On 8/12/2019 12:08 AM, Serhiy Storchaka wrote:
Currently a raw literal cannot end in a single backslash (e.g. in
r"C:\User\"). Although there are reasons for this. It is an old
gotcha, and there are many closed issues about it. This question is
even included in FAQ.
Hmm. I didn't find it documentation, and searching several ways for it
in a FAQ, I wasn't able to find it either.
https://docs.python.org/3/faq/design.html#why-can-t-raw-strings-r-strings-end-with-a-backslash
Thanks for your investigation, Serhiy. Point 3 seems like the easiest
way to convert most regular expressions containing \" or \' from
r"..." form to v"""...""", without disturbing the internal gibberish in
the regular expression, and without needing significant analysis.
No new prefix is needed, since a single trailing backslash is never a
problem in regular expression (as it is an illegal RE syntax).
Regarding point 4, if it is a string literal used as a regexp, internal
triple quotes can be recoded as "{3} and '{3} .
Good point! This is yet one option.
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at
https://mail.python.org/archives/list/python-dev@python.org/message/VR34LGEWNJVNKIFNXW7R3CCHFH6USYTT/