Re: [Python-ideas] What about regexp string litterals : re".*" ?

I feel like that borders on a bit too wordy... Personally, I'd like to see something like Felix's regular definitions: http://felix-lang.org/share/src/web/tut/regexp_01.fdoc#Regular_definitions._... -- Ryan (ライアン) Yoko Shimomura > ryo (supercell/EGOIST) > Hiroyuki Sawano >> everyone else http://refi64.com On Mar 29, 2017 3:30 PM, "Abe Dillon" <abedillon@gmail.com> wrote: My 2 cents is that regular expressions are pretty un-pythonic because of their horrible readability. I would much rather see Python adopt something like Verbal Expressions ( https://github.com/VerbalExpressions/ PythonVerbalExpressions ) into the standard library than add special syntax support for normal REs. On Tue, Mar 28, 2017 at 3:31 AM, Paul Moore <p.f.moore@gmail.com> wrote:
On 28 March 2017 at 08:54, Simon D. <simon@acoeuro.com> wrote:
I believe that the u"" notation in Python 2.7 is defined by while importing the unicode_litterals module.
That's not true. The u"..." syntax is part of the language. from future import unicode_literals is something completely different.
Each regexp lib could provide its instanciation of regexp litteral notation.
The Python language has no way of doing that - user (or library) defined literals are not possible.
And if only the default one does, it would still be won for the beginers, and the majority of persons using the stdlib.
How? You've yet to prove that having a regex literal form is an improvement over re.compile(r'put your regex here'). You've asserted it, but that's a matter of opinion. We'd need evidence of real-life code that was clearly improved by the existence of your proposed construct.
Paul _______________________________________________ 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/

I feel like that borders on a bit too wordy...
I think the use of words instead of symbols is one of the things that makes Python so readable. The ternary operator is done with words: value = option1 if condition else option2 reads almost like English, while: value = condition ? option1: option2; Is just weird. I can read Verbal Expressions very quickly and understand exactly what's going on. If I have a decent IDE, I can write them almost as easily. I see no problem with wordiness if it means I don't have to stare at the code and scratch my head longer, or worse, open a reference to help me translate it (which is invariably the case when I look at regular expressions). On Wed, Mar 29, 2017 at 8:16 PM, Ryan Gonzalez <rymg19@gmail.com> wrote:
I feel like that borders on a bit too wordy...
Personally, I'd like to see something like Felix's regular definitions:
http://felix-lang.org/share/src/web/tut/regexp_01.fdoc# Regular_definitions._h
-- Ryan (ライアン) Yoko Shimomura > ryo (supercell/EGOIST) > Hiroyuki Sawano >> everyone else http://refi64.com
On Mar 29, 2017 3:30 PM, "Abe Dillon" <abedillon@gmail.com> wrote:
My 2 cents is that regular expressions are pretty un-pythonic because of their horrible readability. I would much rather see Python adopt something like Verbal Expressions ( https://github.com/VerbalExp ressions/PythonVerbalExpressions ) into the standard library than add special syntax support for normal REs.
On Tue, Mar 28, 2017 at 3:31 AM, Paul Moore <p.f.moore@gmail.com> wrote:
On 28 March 2017 at 08:54, Simon D. <simon@acoeuro.com> wrote:
I believe that the u"" notation in Python 2.7 is defined by while importing the unicode_litterals module.
That's not true. The u"..." syntax is part of the language. from future import unicode_literals is something completely different.
Each regexp lib could provide its instanciation of regexp litteral notation.
The Python language has no way of doing that - user (or library) defined literals are not possible.
And if only the default one does, it would still be won for the beginers, and the majority of persons using the stdlib.
How? You've yet to prove that having a regex literal form is an improvement over re.compile(r'put your regex here'). You've asserted it, but that's a matter of opinion. We'd need evidence of real-life code that was clearly improved by the existence of your proposed construct.
Paul _______________________________________________ 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/

On Thu, Mar 30, 2017 at 12:47 PM, Abe Dillon <abedillon@gmail.com> wrote:
I feel like that borders on a bit too wordy...
I think the use of words instead of symbols is one of the things that makes Python so readable. The ternary operator is done with words:
value = option1 if condition else option2
reads almost like English, while:
value = condition ? option1: option2;
Is just weird.
I can read Verbal Expressions very quickly and understand exactly what's going on. If I have a decent IDE, I can write them almost as easily. I see no problem with wordiness if it means I don't have to stare at the code and scratch my head longer, or worse, open a reference to help me translate it (which is invariably the case when I look at regular expressions).
However, a huge advantage of REs is that they are common to many languages. You can take a regex from grep to Perl to your editor to Python. They're not absolutely identical, of course, but the basics are all the same. Creating a new search language means everyone has to learn anew. ChrisA
participants (3)
-
Abe Dillon
-
Chris Angelico
-
Ryan Gonzalez