[Tutor] Break, multiple loops

Neil Conway neilconway@home.com
Sat, 27 Nov 1999 00:07:05 -0500 (EST)


Hello all.

I was wondering - is there a way to break cleanly out of multiple loops? The
exact same as a 'break' statement, but out of *all* loops. i.e
---
while 1:
        while 2:
                super_break
---
A normal break statement just leaps out of the first 'while' (if I'm not
mistaken). I would like a statement that leaps out of both loops.

In 'Programming Python' (pg. 193), they have a somewhat similar dilemma, and
they use an 'exitflag' variable to check if the first loop has been broken, and
if it has, execute another 'break'. This seems messy to me: isn't there a
better way? Especially if I want to leap out of, say, 10 loops with 1
'super_break' statement. 

Thanks in advance,

Neil Conway

----------------------------------
E-Mail: Neil Conway <neilconway@home.com>
Date: 27-Nov-1999
Time: 00:00:22

This message was sent by XFMail
----------------------------------