Last active
May 15, 2025 18:42
-
-
Save mattmess1221/3b5c416a2aa75fd9d27c97b99229eafc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LabelBoundary(BaseException): | |
def __enter__(self): | |
return self | |
def __exit__(self, exc_type, exc_value, traceback): | |
return exc_value is self | |
def breakout(self): | |
raise self | |
with LabelBoundary() as label: | |
for x in [1, 2, 3]: | |
for y in [1, 2, 4, 5, 6]: | |
if y == 5: | |
raise label | |
print(x, y) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment