I am a full -1 on this idea - > Two shortcomings: > > 1, Elevating a class in a module (re.Pattern) to language level, this > sounds not very natural. > This makes Python looks like Perl. > > 2, We can't use regex module as a drop-in replacement: import regex as re > IMHO, I would like to see regex module be adopted into stdlib after > cutting off its "full case-folding" and "fuzzy matching" features. >
Sorry for sounding over-reactive, but yes, this could make Python look like Perl. I think one full advantage of Python is exactly that regexps are treated fairly, with no special syntax. You call a function, or build an instance, and have the regex power, and that is it. And you can just plug any third-party regex module, and it will work just like the one that is built-in the language. This proposal at least keep the ' " ' quotes - so we don't end up like Javascript which has a "squeashy regexy" thing that can sneak in code and you are never sure when it is run, or even if it can be assigned to a variable at all. I am quite sure that if the mater is performance, a way to pickle, or somehow store pre-compiled regexes can be found without requiring special syntax. And a 3rd shortcoming - flags can't be passed as parameters, and have to be built-in the regexp themselves, further complicating the readability even for very simple regular expressions. Other than that it would not be much different from the ' f" ' strings thing, indeed, On Thu, 27 Dec 2018 at 09:49, Ma Lin <malin...@163.com> wrote: > Related links: > > [2] Chris Angelico conceived of "compiled regexes be stored in .pyc > file" in March 2013. > [2] https://mail.python.org/pipermail/python-ideas/2013-March/020043.html > > [3] Ken Hilton conceived of "Give regex operations more sugar" in June 2018. > [3] https://mail.python.org/pipermail/python-ideas/2018-June/051395.html > > _______________________________________________ > Python-ideas mailing list > Python-ideas@python.org > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/