This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author apalala
Recipients apalala
Date 2019-12-30.13:19:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1577711945.6.0.0241743491206.issue39165@roundup.psfhosted.org>
In-reply-to
Content
The problematic `findall(...)[0]` is a common anti-pattern in Python programs. The reason is lack of symmetry and completeness in the `re` module.

The original proposal in `python-ideas` was to add `re.findfirst(pattern, string, flags=0, default=_mark)` with more or less the semantics of `next(findall(pattern, string, flags=flags), default=default)`. 

The referenced PR adds `findalliter(pattern, string, flags=0)` with the value semantics of `findall()` over a generator, implements `findall()` as `return list(findalliter(...))`, and implements `findfirst()`. 

Consistency and correctness are likely because all tests pass with the redefined `findall()`.
History
Date User Action Args
2019-12-30 13:19:05apalalasetrecipients: + apalala
2019-12-30 13:19:05apalalasetmessageid: <1577711945.6.0.0241743491206.issue39165@roundup.psfhosted.org>
2019-12-30 13:19:05apalalalinkissue39165 messages
2019-12-30 13:19:05apalalacreate