On Tue, Dec 8, 2020 at 3:31 PM Ricky Teachey <ri...@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. > 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.
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@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/DGK3IH7CVZSFR2G45THGVKIFTDOGVLGQ/ Code of Conduct: http://python.org/psf/codeofconduct/