On Tue, Dec 8, 2020 at 3:31 PM Ricky Teachey
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.
for outer in range(5): with breakable() as brk: for middle in range(5): for inner in range(10): print(outer, middle, inner) if middle == 1 and inner == 5: brk() print(f"end middle loop #{middle}") print(f"end outer loop #{outer}") print("done")
-- The dead increasingly dominate and strangle both the living and the not-yet born. Vampiric capital and undead corporate persons abuse the lives and control the thoughts of homo faber. Ideas, once born, become abortifacients against new conceptions.