I recently read this question which had a solution about labeling loops in Java.
I am wondering if such a loop-naming system exists in Python. I have been in a situation multiple times where I do need to break out of an outer for
loop from an inner for
loop. Usually, I solve this problem by putting the inner loop in a function that returns (among others) a boolean which is used as a breaking condition. But labeling loops for breaking seems a lot simpler and I would like to try that, if such functionality exists in python.
Does anyone know if it does?
There was a proposal to include named loops in python PEP3136, however, it was rejected with an explanation here. The rejection was mostly due to the rare number of circumstances where code readability would be improved by including this construct.