
I feel like this is all example of "not every one line function needs to be in the standard library." You can easily write your own 'match_or_raise()'... I guess it would take two lines, actually. On Sat, Oct 21, 2023, 2:42 PM Ram Rachum <ram@rachum.com> wrote:
Hey,
I bet this has been discussed before but I couldn't find it. I'd appreciate it if anyone could point me to that thread.
I'm sick of seeing "AttributeError: 'NoneType' object has no attribute 'foo'" whenever there's a `re.match` operation that fails while the code expects it to succeed. What do you think about a flag `require` such that `re.match(pattern, string, require=True)` would either return a match or raise an exception with an actually useful message?
Thanks, Ram. _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-leave@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/PLF46R... Code of Conduct: http://python.org/psf/codeofconduct/