11.08.19 23:07, Glenn Linderman пише:
On 8/11/2019 1:26 AM, Serhiy Storchaka wrote:
10.08.19 22:10, Glenn Linderman пише:
I wonder how many raw strings actually use the \" escape
productively? Maybe that should be deprecated too! ? I can't think
of a good and necessary use for it, can anyone?
This is an interesting question. I have performed some experiments. 15
files in the stdlib (not counting the tokenizer) use \' or \" in raw
strings. And one test (test_venv) is failed because of using them in
third-party code. All cases are in regular expressions. It is possible
to rewrite them, but it is less trivial task than fixing invalid
escape sequences. So changing this will require much much more long
deprecation period.
Couldn't they be rewritten using the above idiom? Why would that be less
trivial?
Or by using triple quotes, so the \" could be written as " ? That seems
trivial.
Yes, they could. You can use different quote character, triple quotes,
string literal concatenation. There are many options, and you should
choose what is applicable in any particular case and what is optimal.
You need to analyze the whole string literal and code transformation
usually is more complex than just duplicating a backslash or adding the
`r` prefix. For example, in many cases `\"` can be replaced with
`"'"'r"`, but it does not look pretty readable.
See https://github.com/python/cpython/pull/15217.
_______________________________________________
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/KSOBUCTZITXAI3KG77DVST7U4DBPPKGR/