Building several parsing modules

Diez B. Roggisch deets at nospam.web.de
Mon Mar 19 06:54:11 EDT 2007


Robert Neville wrote:

> Basically, I want to create a table in html, xml, or xslt; with any
> number of regular expressions; a script (Perl or Python) which reads
> each table row (regex and replacement); and performs the replacement
> on any file name, folder, or text file (e.g. css, php, html).  For
> example, I often rename my mp3 (files); the folder holding the mp3
> files; and replace these renamed values in a playlist/m3u/xml file.

<snip/>

Don't do it. Just write python for the task at hand - if it involves regular
expressions, use the re module if you must, but lots of stuff can be done
with simpler, less confusing means like string.split and the like.

The result should be a small few-liner. You are way better off with that,
especially when you have to take constraints into account like moon phase
or the like - you then have the full power of python at your hand, instead
of inventing some wicked table-based "language" that you code exceptions
into.

Diez



More information about the Python-list mailing list