Working around a lack of 'goto' in python

Mel Wilson mwilson at
Mon Mar 8 16:43:00 CET 2004

In article <vpbth1-drb.ln1 at>,
"Roger Binns" <rogerb at> wrote:
>> > What you have is what many other languages allow with integers after break or
>> > continue statements.  For example you can do 'break 2' or 'continue 3' to
>> > break or continue out of the respective number of enclosing for loops.
>> Yuck.  Bletch.  Barf.
>Care to expand on that?  It is a construct present in shell scripting

Well, say you decide that several lines of code should be executed
repeatedly.  You can stick in the while...: , your editor can indent
the block, then you have to hunt for numbered `continue` and `break` and
increment some, but not all of the numbers.  Unnumbered `continue` and
`break` cause similar trouble, but the trouble is guaranteed to be more
local.  For non-local I much prefer the exit-by-exception.

        Regards.        Mel.

More information about the Python-list mailing list