Python regular expressions just ain't PCRE

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Sat May 5 02:19:18 EDT 2007


In <1178323901.381993.47170 at e65g2000hsc.googlegroups.com>, Wiseman wrote:

> Note: I know there are LALR parser generators/parsers for Python, but
> the very reason why re exists is to provide a much simpler, more
> productive way to parse or validate simple languages and process text.
> (The pyparse/yappy/yapps/<insert your favourite Python parser
> generator here> argument could have been used to skip regular
> expression support in the language, or to deprecate re. Would you want
> that? And following the same rule, why would we have Python when
> there's C?)

I don't follow your reasoning here.  `re` is useful for matching tokens
for a higher level parser and C is useful for writing parts that need
hardware access or "raw speed" where pure Python is too slow.

Regular expressions can become very unreadable compared to Python source
code or EBNF grammars but modeling the tokens in EBNF or Python objects
isn't as compact and readable as simple regular expressions.  So both `re`
and higher level parsers are useful together and don't supersede each
other.

The same holds for C and Python.  IMHO.

Ciao,
	Marc 'BlackJack' Rintsch



More information about the Python-list mailing list