Named loops for breaking
jeanmichel at sequans.com
Wed Mar 10 14:22:36 CET 2010
Daniel Klein wrote:
> I did a little searching and couldn't really find much recent on this.
> The only thing I found was this:
> Basically I'm wondering if there are any plans to implemented named
> loops in Python, so I can tell a break command to break out of a
> specific loop in the case of nested loops. Currently I'm using boolean
> flag variables, but I find that very clumsy. I know this idea of
> too. It just seems a very Pythonian idea to me: clear, promotes code
> legibility, seems obvious.
Strange that I've rarely been in need of such feature. Continues &
breaks are mess-prone, adding an 'outter block' break feature would just
increase the messing potential of such controls.
Just my opinion though.
Still there's a control that is able to break outter scopes : return.
So embed your loop in a function and you'll be able to break whenever
More information about the Python-list