>    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. 

/ Anders
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to