How to label loops?
steffen.ries at sympatico.ca
Sun Feb 11 20:35:53 CET 2001
Zamurai <zamurai at gmx.net> writes:
> "Steve Holden" <sholden at holdenweb.com> wrote:
> > First, convince me that loops need labelling!
> for example:
> while 1: # first loop
> while 1: # second loop
> this break breaks only out of the first loop, but what, if i want to
> break out of the first loop, while i´m in the second one?
one way is to use control variables, e.g.:
outer_active = 1
inner_active = 1
outer_active = 0
another way would be to use exceptions, e.g.:
raise Exception, "broken loop"
steffen.ries at sympatico.ca <> Gravity is a myth -- the Earth sucks!
More information about the Python-list