PyWart: Python regular expression syntax is not intuitive.
rantingrickjohnson at gmail.com
Wed Jan 25 19:14:09 EST 2012
On Jan 25, 5:36 pm, Ian Kelly <ian.g.ke... at gmail.com> wrote:
> On Wed, Jan 25, 2012 at 2:19 PM, Rick Johnson
> <rantingrickjohn... at gmail.com> wrote:
> > I disagree here.
> > Whist some people may be "die-hard" fans of the un-intuitive perl
> > regex syntax, i believe many, if not exponentially MORE people would
> > like to have a better alternative. Do i want to remove the current
> > "well established" re module? No. But i would like to create a new
> > regex module that is more pythonic. A regex module that we can be
> > proud of. And just maybe, a regex module that "sets the bar" for all
> > other regular expressions.
> Compact regex notations are inherently unpythonic. While your
> reimplementation may be more intuitive to you, I don't think that it's
> more pythonic at all.
Regexps will never be "truly Pythonic". By their very nature they must
be implicit, complicated, most times nested and dense, not as readable
as we'd like, special cases everywhere, not very practical, hard(sic)
to explain, and just plain cryptic. They violate almost every aspect
of the zen. The point is NOT to make regexes "Pythonic", the point is
to make them as "Pythonic" as we can and not a bit more. I discussed
this very topic earlier, did you miss my speech? I though it was quite
Rick Johnsons stump speech 2.0: """ The greatest aspect of regexes is
their compactness, and not only should we keep them compact, we should
celebrate their compactness. It is in that respect that regexes will
always be cryptic to the neophyte, however, we must NEVER allow
regexes to be a scourge on the initiated, no. We must balance the
compact and the intuitive natures of regexes until we reach a natural
harmony. But most importantly, we must understand that these aspects
of regexes are NOT mutually exclusive -- for it is our understanding
that is flawed."""
> > I know about PyParsing but i believe we have room for PyParsing and a
> > more Pythonic take on Perl style regular expressions. I don't see why
> > we could not keep all three. Let the people decide what is best for
> > them.
> PyParsing produces recursive descent parsers. It's an alternative to
> regular expressions for a different class of parsing problems, not a
> replacement, and so it's not particularly germane to this discussion.
It is germane in the fact that i believe PyParsing, re, and my new
regex module can co-exist in harmony.
More information about the Python-list