On Thu, 3 Dec 2020 at 11:07, Jonatan <pybots...@gmail.com> wrote: > > Hi, sometimes I do nested loops and I want to break specific loop, > outer/inner etc. > I need to do an ugly thing with for..else and it's annoying. > > It'd be nice if we could do so: > for i in range(10) as loop_i: > for j in range(i, i + 10) as loop_j: > if i + j == 9: > break loop_i > or something like this. > Please comment what do you think about this idea.
Usually, in real world examples where this comes up, it's possible (and better) to refactor the inner loop into a named generator function. As a result, cases where such a feature would be useful are not as common as it initially seems. Paul _______________________________________________ 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/3DX45H7YJ7GHLKP3AIERLHTANBDBQDJ4/ Code of Conduct: http://python.org/psf/codeofconduct/