[issue9529] Make re match object iterable

Serhiy Storchaka report at bugs.python.org
Fri Aug 1 13:21:24 CEST 2014


Serhiy Storchaka added the comment:

I think MizardX means that match object should be iterable. This will allow sequence unpacking.

>>> import re
>>> m = re.match(r'(\w+):(\w+)', 'qwerty:asdfgh')
>>> k, v = m
>>> k
'qwerty'
>>> v
'asdfgh'

This idea looks reasonable to me. Here is simple preliminary patch which implements it.

----------
keywords: +patch
nosy: +serhiy.storchaka
stage: needs patch -> patch review
title: Converge re.findall and re.finditer -> Make re match object iterable
type: behavior -> enhancement
versions: +Python 3.5 -Python 3.2
Added file: http://bugs.python.org/file36192/re_matchobj_iterable.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9529>
_______________________________________


More information about the Python-bugs-list mailing list