06.12.19 04:31, Guido van Rossum пише:
(There are apparently subtle differences between re.search() and re.findall() -- not sure if they matter in this case.)

There is no any differences.

Also, analyzing examples from GitHub, in most cases the pattern contains no or single group, so the code can be written as (if no groups)

    result = (re.search(pattern, string) or [default])[0]

or (is a single group)

    result = (re.search(pattern, string) or ['', default])[1]

And since most code do not handle the case when the pattern is not found in any case, it can be simplified even more.
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/PTZKHHPQYR336R5G5YGSCBYJJRRVBLUP/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to