04.12.19 03:46, Oscar Benjamin пише:
result = next(re.finditer(...), None)
if result is None:
     # raise or something
else:
     # use result

`next(re.finditer(...), None)` is a weird way of writing `re.search(...)`.

`next(re.finditer(...), defaults)` is the same as `re.search(...) or defaults`.
_______________________________________________
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/5ON2U3ZXJBHYOQH3XIGQRN3JHTNCJSKD/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to