On Wed, Dec 4, 2019 at 16:33 Juancarlo Añez <juancarlo.a...@gmail.com <mailto:juancarlo.a...@gmail.com>> wrote:
    The OP thinks that the case for wanting just the string for a first
    regex match, or a verifiable default if there is no match, is way
    too common, that the advice on the web is not very good (it should
    be "write a findfirst() using next() over finditer()", and that
    novices default to using findall(..)[0], which is troublesome.

    The proposed implementation of a findfirst() would handle many
    common cases, and be friendly to newcomers (why do I need to deal
    with a Match object?), specially if the semantics are those of
    *findall()*:

          next(iter(findall(...)), default=default)

Could you show us a real code that uses it?
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/2FNSNEEKDWWYY6II6MTSBWEEPTF5B3VW/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to