On 8/12/2019 12:11 AM, Serhiy Storchaka wrote:
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.
No, that is not readable. But neither does it seem to be valid syntax,
or else I'm not sure what you are saying. Ah, maybe you were saying that
a seqence like the '\"' that is already embedded in a raw string can be
converted to the sequence `"'"'r"` also embedded in the raw string. That
makes the syntax work, but if that is what you were saying, your
translation dropped the \ from before the ", since the raw string
preserves both the \ and the ".
Regarding the readability, I think any use of implicitly concatenated
strings should have at least two spaces or a newline between them to
make the implicit concatenation clearer.
_______________________________________________
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/VGFQFBKNPNKBJLOPDHQWGCJ6WPK7IDKT/