Python: How to ignore an exception and proceed?

The.Anti.9 picture The.Anti.9 · Feb 22, 2009 · Viewed 545.6k times · Source

I have a try...except block in my code and When an exception is throw. I really just want to continue with the code because in that case, everything is still able to run just fine. The problem is if you leave the except: block empty or with a #do nothing, it gives you a syntax error. I can't use continue because its not in a loop. Is there a keyword i can use that tells the code to just keep going?

Answer

Andy Hume picture Andy Hume · Feb 22, 2009
except Exception:
    pass

Python docs for the pass statement