I'm more and more convinced as time goes on that we should just stop trying to interpret raw strings as regexps.
I think you are probably right. Does anyone else have an opinion on this?
Well - as you pointed out previously, raw strings were introduced into Python for the specific purpose of making writing regexps easier. If we don't interpret raw strings as regexes, what will we interpret as regexes in Python, then? Or will we just ditch regex syntax highlighting from Python altogether?
Perhaps we need some sort of obvious marker on the same line to indicate that a raw string should be interpreted as a regex. Regexes in Python are pretty obvious when being used - a very common way is to compile a regex via re.compile([raw string]), and the other common way is to call other functions in the regex module, ala re.findall (r'\bFig\b'), for instance.
So, perhaps raw strings should only be interpreted as regexes when directly preceded by re.[function]( - while this would not get everything we might want to be interpreted as a regex, it would capture some of the most common use cases.
Nick
Fabry Nicholas F. wrote:
I'm more and more convinced as time goes on that we should just stop trying to interpret raw strings as regexps.
I think you are probably right. Does anyone else have an opinion on this?
Or will we just ditch regex syntax highlighting from Python altogether?
This was my thought. I dunno... I don't tend to use raw strings for anything else, or at least nothing else with conflicting syntax, so it's not *that* much of a problem for me personally. But several people have had highlighting break on various stuff because of the regexp highlighting.
So, perhaps raw strings should only be interpreted as regexes when directly preceded by re.[function]( - while this would not get everything we might want to be interpreted as a regex, it would capture some of the most common use cases.
This would be fine too (i.e. cause no problems), but would complexify the grammar.
-Jacob