[Python-ideas] In fact, I'm a bit worry about this literal p""
boxed at killingar.net
Mon Dec 31 07:07:56 EST 2018
> regex = re.compile(r"...")
> regex = p("...")
> is not that much different.
True, but when the literal is put somewhere far from the compile() call it becomes a problem for static analysis. Conceptually a regex is not a string but an embedded foreign language. That's why I think this discussion is worth having. It would be nice with a way to mark up foreign languages in a way that had some other advantages so people would be incentivised to do it, but just a way to mark it with comments would be fine too I think if it's standardized.
Maybe the discussion should be expanded to cover the general case of embedded foreign languages? SQL, HTML, CSS and (obviously) regex comes to mind. One could also think of C for stuff like CFFI.
More information about the Python-ideas