A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2001-October/018121.html below:

[Python-Dev] iterator support for SRE?

[Python-Dev] iterator support for SRE?Guido van Rossum guido@python.org
Wed, 24 Oct 2001 23:35:56 -0400
> a common wish for SRE is a variant of findall that returns
> all match objects, instead of the strings.
> 
> recently, I realized that the internal scanner type (originally
> added to speed up Python versions of findall/sub/split) can
> be wrapped in an iterator, allowing the user to loop over all
> matches.
> 
> >>> import re
> >>> p = re.compile(somepattern)
> >>> for match in iter(p.scanner(somestring).search, None):
> >>>     print match.groups()
> 
> 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.

--Guido van Rossum (home page: http://www.python.org/~guido/)



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4