On Dec 4, 2019, at 14:56, Oscar Benjamin
My suggestion would be to use a function rather than exceptions:
stuff = [10, 20, 30] other_stuff = [1, 2, 3]
def func(): for x in stuff: for y in other_stuff: print(x, y) if x + y > 21: return
func()
In this example it might seem awkward to introduce a function just for this but normally in context the function can have a more reasonable purpose and a good name and return something useful etc.
I think the majority of the time, refactoring it into a function actually makes it better, or at least neutral. The problem is that occasionally it really does make it significantly worse, and that’s when you really wish named break existed. But I think two people already said that’s about once/year for them? That sounds about right to me, too.