On Tue, Dec 8, 2020 at 10:42 AM David Mertz <mertz@gnosis.cx> wrote:
On Tue, Dec 8, 2020 at 3:31 PM Ricky Teachey <ricky@teachey.org> wrote:
I agree with the person who called this a brilliant solution. Here is the code from the link for completeness:

I'm not diss'ing the approach.  But it doesn't really save that much over a sentinel variable `break_to_middle`.  And if you wanted to break to any of several levels from the innermost, you'd need multiple context managers.
 

Fair enough. For me the "brilliance" comes in how readable it comes out to be; I find it far easier to scan through and understand (without even looking at the brk() function to see what it does) the first time through then the sentinel approach. My syntax suggestion came from thinking about how to make it even more readable (providing one can swallow the "this decorator automatically becomes a context manager" part-- which might be too hard to swallow I don't know).

---
Ricky.

"I've never met a Kentucky man who wasn't either thinking about going home or actually going home." - Happy Chandler