Author serhiy.storchaka
Recipients MizardX, ezio.melotti, moreati, mrabarnett, serhiy.storchaka, timehorse
Date 2014-08-01.12:02:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <11925142.c1akzAufYZ@raxxla>
In-reply-to <>
Yes, but the purpose of this feature is to simplify the use of finditer() in 
the "for" loop.

>>> import re
>>> for k, v in re.finditer(r"(\w+):?(\w+)?", "ab:cd\nef\n"):
...     print(k, v)
ab cd
ef None

Currently you should either unpack manually:

    for m in re.finditer(...):
        k, v = m.groups()

This way doesn't work well with comprehensions.

Or use the operator module:

    import operator
    for k, v in map(operator.methodcaller('groups'), re.finditer(...)):

This way is too verbose and unclear.

Sorry, previous version of the patch had reference leak.
File name Uploaded
re_matchobj_iterable.patch serhiy.storchaka, 2014-08-01.12:02:13
Date User Action Args
2014-08-01 12:02:14serhiy.storchakasetrecipients: + serhiy.storchaka, timehorse, ezio.melotti, mrabarnett, moreati, MizardX
2014-08-01 12:02:14serhiy.storchakalinkissue9529 messages
2014-08-01 12:02:14serhiy.storchakacreate