[Python-Dev] Re: pre-PEP: Complete, Structured Regular Expression Group Matching

Michael Hudson mwh at python.net
Sat Aug 7 16:16:09 CEST 2004


Mike Coleman <mkc at mathdogs.com> writes:

> Michael Hudson <mwh at python.net> writes:
>> Generally, it strikes me as mildly useful.  An implementation would
>> surely help :-)
>
> If yours is the most positive review, there probably won't be one.  :-)

Well, I thought *someone* should say *something*, just to stop the
proto-pep being lost.  Have you sent it to the PEP editor yet?  I
think it's ready enough.

The reason that I only said "mildly useful" was because I didn't think
"OMG!  I would so have liked to use this yesterday" or anything like
that...

> Seriously, though, I'd readily concede that there are different
> approaches to solving this problem, and I was hoping for some
> feedback and suggestions before I start whacking at the code.  I
> also have considered the possibility that although this has been
> driving me nuts that few others will care--if this is true, it
> probably *shouldn't* go in the core libraries.

It depends a bit on whether it can be implemented as an addition in a
non-painful way, or whether editing the sre code makes it very much
easier.  I don't know the answer, mind.

>>> [mismatch index return]
>> I don't really like this idea; it seems to be that it would be more
>> helpful to raise an exception and attach this data to the exception.
>> But that's a bit inconsisent with how match and search work.
>
> Hmm.  Yeah, if it weren't for the value of matching re.match semantics, it
> would make a lot more sense for this to be an exception.  As it is, I could
> see it going either way. 

I think you could make a case for raising an exception; the point of
structmatch is to extract information, whereas at least sometimes you
call re.match just to see if the data matches the pattern.

> Or I suppose you could add a flag to determine which (but ugh).

Err, let's not go there.

Cheers,
mwh

-- 
  Lisp nearing the age of 50 is the most modern language out
  there. GC, dynamic, reflective, the best OO model extant including
  GFs, procedural macros, and the only thing old-fashioned about it 
  is that it is compiled and fast.   -- Kenny Tilton, comp.lang.python


More information about the Python-Dev mailing list