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

Mike Coleman mkc at mathdogs.com
Wed Aug 11 05:01:21 CEST 2004


Erik Heneryd <erik at heneryd.com> writes:
> 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.

It concerns me a little, too.  No doubt the documentation could be better.
But if you're already familiar with re.match and structure interpolation (or
whatever it's called):

        x = 1
        y = [3, 4, 5]
        z = [x, y, [x]]
        z -> [1, [3 4, 5], [1]]

then to me it has a certain ring of familiarity.

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

I absolutely agree on not being silent on error.  The alternative would be to
return an error index (i.e., an integer) on error and then have the caller
observe the type of the return value (integer on failuer, list on success) to
determine success.  But again, throwing an exception does seem more natural.

> 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>

Impressive--I thought that'd take a lot more code.  I'll study it.  Thanks for
taking up the challenge!

Mike



More information about the Python-Dev mailing list