On 10/23/2015 14:40, Ned Batchelder
wrote:
On 10/22/15 6:56 PM, Yury Selivanov wrote:
In
principle, there is no reason why *both*
of these groups
of users can't use one tool and be happy. I propose to
establish a convention in PEP 8, explaining that, while both
literals are semantically equivalent,
- r'..' strings *should*
be used for regexps,
- R'..' strings *should*
be used for unstyled raw strings,
and tools *should* treat them as such.
All of this is merely about codifying the current status quo.
But you are not codifying the status quo. The distinction you are
proposing is one that you have invented. I have never used R""
strings.
I think the best solution to the problem is to improve the
highlighters, and luckily you have written one! To me, it is
clear which of these strings is the regex:
r"\d+"
r"\dir"
If the highlighters tried some heuristics, they could do a better
job "being helpful" by making better guesses about the meaning of
programs. I don't mind when highlighters make wrong guesses, as
long as they don't ruin the entire rest of the file. But better
guesses will be better. :)
--Ned.
it should be noted that most regexes are also valid paths on NTFS.
is r'\dir[a-zA-Z0-9]\\' a path or a regex?