[Python-Dev] iterator support for SRE?

Fredrik Lundh fredrik@pythonware.com
Fri, 26 Oct 2001 11:38:29 +0200


guido wrote:
> > how about adding a "finditer" method, which takes care of
> > the low-level setup:
> >
> > >>> for match in p.finditer(somestring):
> > >>>     print match.groups()
> >
> > or should we just make the scanner factory an official part
> > of the SRE interface?
>
> Or both?  The scanner interface seems vaguely useful as a low-level
> tool to create other higher-level variants; but the finditer() call
> seems to nicely capture a common case.

as you might have noticed, I went ahead and checked in code
for "finditer".  nobody has complained this far ;-)

isn't "iterfind" a better name, btw?  more like "iterkeys" (etc).

if nobody complains, I'll change the name, and check in some
documentation.

:::

will have to think about scanner; I agree that it may seem to
be vaguely useful, but cannot think of a use case that isn't
better handled by findall/split/sub or iterfind.  can anyone?

</F>