Abe Dillon writes:

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

You think that example is more readable than the proposed transalation

    ^(http)(s)?(\:\/\/)(www\.)?([^\ ]*)$

which is better written

    ^https?://(www\.)?[^ ]*$

or even

    ^https?://[^ ]*$

which makes it obvious that the regexp is not very useful from the
word "^"?  (It matches only URLs which are the only thing, including
whitespace, on the line, probably not what was intended.)

Are those groups capturing in Verbal Expressions?  The use of "find"
(~ "search") rather than "match" is disconcerting to the experienced
user.  What does alternation look like?  How about alternation of
non-trivial regular expressions?  Etc, etc.

As far as I can see, Verbal Expressions are basically a way of making
it so painful to write regular expressions that people will restrict
themselves to regular expressions that would be quite readable in
traditional notation!  I don't think that this failure to respect the
developer's taste is restricted to this particular implementation,
either.  They *are* regular expressions, just with a verbose,
obstructive notation.

Far more important than "more readable" regular expressions would be a
parsing library in the stdlib, reducing the developer's temptation to
parse using complex regular expressions.  IMHO YMMV etc.

Steve
_______________________________________________
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