[issue9529] Converge re.findall and re.finditer
Matthew Barnett
report at bugs.python.org
Sat Aug 7 20:45:09 CEST 2010
Matthew Barnett <python at mrabarnett.plus.com> added the comment:
Ah, I see what you mean. I still think you're wrong, though! :-)
The 'for' loop is doing is basically this:
it = re.finditer(r'(\w+):(\w+)', text)
try:
while True:
match_object = next(it)
# body of loop
except StopIteration:
pass
re.finditer() it returns a generator which yields match objects.
What I think you're actually requesting (but not realising) is for the 'for' loop not just to iterate over the generator, but also over what the generator yields.
If you want re.finditer() to yield the groups then it has to return a generator which yields those groups, not match objects.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9529>
_______________________________________
More information about the Python-bugs-list
mailing list