Ignoring an error message to continue with the loop in python

Ignoring an error message to continue with the loop in python

It is generally a bad practice to suppress errors or exceptions without handling them, but this can be easily done like this:

try:
    # block raising an exception
except:
    pass # doing nothing on exception

This can obviously be used in any other control statement, such as a loop:

for i in xrange(0,960):
    try:
        ... run your code
    except:
        pass

Ignoring an error message to continue with the loop in python

Leave a Reply

Your email address will not be published.