views:

635

answers:

4

I have a loop going, but there is the possibility for exceptions to be raised inside the loop. Which of course would stop it all together. I want to catch the exceptions and basically just skip to the next iteration in the loop. Is there a keyword or way to do this?

+3  A: 

Something like this?

for i in xrange( someBigNumber ):
    try:
        doSomethingThatMightFail()
    except SomeException, e:
        pass
S.Lott
+8  A: 

You are lookin for continue.

André
+2  A: 

I think you're looking for continue

Jason Punyon
+5  A: 
for i in iterator:
    try:
        # Do something.
        pass
    except:
        # Continue to next iteration.
        continue
Fara