Python 2.4 | 7.3 The for statement
brainsucker
jrodrigog at gmail.com
Fri Mar 25 18:41:25 EST 2005
Franciso, some more code.
Breaking with two conditions, and fun with exceptions:
moflo = 1
try:
for item1 in range(10):
if (item1 * moflo) == 3: raise StopIteration
for item2 in range(10):
if (item2 * moflo) == 2: raise StopIteration
print "Let's see"
except StopIteration:
pass
As oppossed to:
leave = False
moflo = 1
for item1 in range(10) until ((item1 * moflo) == 3) or leave:
for item2 in range(10) until leave:
if (item2 * moflo) == 2: leave = True
print "Let's see"
What can I say.
More information about the Python-list
mailing list