Python 2.4 | 7.3 The for statement
brainsucker
jrodrigog at gmail.com
Thu Mar 24 22:49:38 EST 2005
>And that could be modified even further, using current
>(unextended) Python...
Nice code Wulfraed (or Dennis), back to the basics:
-- Your code
foo = 0
for item1 in range(10):
for item2 in range(10):
foo = item1 + item2
if foo == 2:
print "Let's see"
break # let's go
if (item1 + item2) == 2:
break # one more time
print foo
(7)
-- Another version
foo = 0
for item1 in range(10) until foo == 2:
for item2 in range(10) until foo == 2:
foo = item1 + item2
if foo == 2: print "Let's see"
print foo
# ~40% lines off on the n^2 breaking loop
PD: This for helps avoiding python bytecode too.
PD2: Nice pictures and links on your webpages Wulfraed. :)
PD3: Just don't imagine a n^16 breaking loop, could that exist?
More information about the Python-list
mailing list