On Sat, Aug 01, 2020 at 03:57:34PM +1000, Chris Angelico wrote:
Ahh, okay. So it's safe in the sense that it can't accidentally leak a confusing exception. Unfortunately a lot of people are going to assume that it means "will always give a useful return value". Definitely worth being very very clear about the semantics.
What you name the function is up to you :-)
And it's really not the ideal semantics here anyway. What you actually want is ValueError if the dict is empty.
Your wish is my command:
mynext = exception_guard(catch=StopIteration, throw=ValueError)(next)