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

Erik Heneryd erik at heneryd.com
Tue Aug 10 14:57:10 CEST 2004


Mike Coleman wrote:
> Paul Moore <pf_moore at yahoo.co.uk> writes:

>>The only other comment I have is that the semantics seem pretty
>>complex - I think that in practice, they do more or less what you want
>>them to, but the description is pretty obscure.

I'd say that is probably a warning flag, but I don't know, at the same 
time it looks like it could be kind of useful.

>>And although I can see that the error return has some value, I suspect that
>>it might actually complicate real use.
> 
> 
> Someone else suggested throwing an exception instead, which I'm now leaning in
> favor of, too.

Exceptions are the way to go.  You should get what you ask for, or a 
heads up.  Errors should never pass silently.

> 
> 
>>A suggestion - would it be possible to implement re.structmatch as a
>>pure Python prototype, to thrash out some of the usability questions?
>>If the function appears valuable in such a form, arguing for
>>incorporation into the re module would be a lot easier.
> 
> 
> I suspect that in this case a pure Python implementation might actually be a
> lot harder than implementing it as a C patch.  This is because so much of the
> work is already done in the current re module; the C patch would probably not
> be that big.  In order to do it in Python I'd end up reimplementing re.match
> in Python, which I wouldn't look forward to.

I hacked up a Python prototype, mostly as a challenge.  It's brittle and 
it's ugly, but it kind of works.  Though, if /F says it would require a 
major rewrite of the C-engine, that's probably true... <wink>


Erik

-------------- next part --------------
A non-text attachment was scrubbed...
Name: structmatch.py
Type: text/x-python
Size: 5760 bytes
Desc: not available
Url : http://mail.python.org/pipermail/python-dev/attachments/20040810/a5e602ab/structmatch.py


More information about the Python-Dev mailing list