why no break N levels, as in other leading languages?

Chad Netzer cnetzer at mail.arc.nasa.gov
Thu May 1 20:03:17 EDT 2003


On Thu, 2003-05-01 at 12:52, Dan Jacobson wrote:
> In bash there is
> $ help break
> break: break [n]
>     Exit from within a FOR, WHILE or UNTIL loop.  If N is specified,
>     break N levels.
> 
> In python did that Guido fella (who by the way looks like he's the
> kind of kid who gets picked on by bullies, [blah blah blah]

After a quick check of your website I must say that... well...
nevermind.

> ... oops, where were we? Anyway, in python did he forget
> about giving it a N ability or is there of course some higher
> principle involved?

He did not forget it.  It is just a completely dumb idea for a feature
that I'm sure it never even came close to entering his mind.

If you REALLY must abort from deep inside nested loops (or recursion),
without using a boolean flag value to control the continued looping (or
recursion), you could raise an exception (an of course catch it outside
all the loops (or recursion).

-- 

Chad Netzer
(any opinion expressed is my own and not NASA's or my employer's)






More information about the Python-list mailing list