3 ms·
Python has coroutines (in the original sense), so one can implement almost Break-break. For example, it's easy to implement an object so that this will work as
by henrydark 4y ago
Python has coroutines (in the original sense), so one can implement almost Break-break. For example, it's easy to implement an object so that this will work as expected:
from easytowritelibrary import LoopManager
lm = LoopManager()
for x in lm(a1):
for y in lm(a2):
if cond:
lm.break_(2); break
block()
It can support stuff like:
for x in lm(a1, "a1"):
for y in lm(a2, "a2"):
if cond1:
lm.break_("a1"); break
if cond2:
lm.continue_("a1"); break
block()
It can't handle "for-else" correctly, but maybe that's OK.