Python and Regular Expressions
Steven D'Aprano
steve at REMOVE-THIS-cybersource.com.au
Sat Apr 10 21:23:56 EDT 2010
On Sat, 10 Apr 2010 10:11:07 -0700, Patrick Maupin wrote:
> On Apr 10, 11:35 am, Neil Cerutti <ne... at norwich.edu> wrote:
>> On 2010-04-10, Patrick Maupin <pmau... at gmail.com> wrote:
>> > as Pyparsing". Which is all well and good, except then the OP will
>> > download pyparsing, take a look, realize that it uses regexps under
>> > the hood, and possibly be very confused.
>>
>> I don't agree with that. If a person is trying to ski using pieces of
>> wood that they carved themselves, I don't expect them to be surprised
>> that the skis they buy are made out of similar materials.
>
> But, in this case, the guy ASKED how to make the skis in his woodworking
> shop, and was told not to be silly -- you don't use wood to make skis --
> and then directed to go buy some skis that are, in fact, made out of
> wood.
As entertaining as this is, the analogy is rubbish. Skis are far too
simple to use as an analogy for a parser (he says, having never seen skis
up close in his life *wink*). Have you looked at PyParsing's source code?
Regexes are only a small part of the parser, and not analogous to the
wood of skis.
Perhaps a better analogy would be a tennis racket, with regexes being the
strings. You have a whole lot of strings, not just one, and they are held
together with a strong framework. Without the framework the strings are
useless, and without the strings the racket doesn't do anything useful.
Using this analogy, I would say the OP was wanting to play tennis with a
single piece of string, and asking for advise on beefing it up to make it
work better. Perhaps a knot tied in one end will help?
--
Steven
More information about the Python-list
mailing list