Sometimes, we want to properly ignore exceptions with Python.
In this article, we’ll look at how to properly ignore exceptions with Python.
How to properly ignore exceptions with Python?
To properly ignore exceptions with Python, we can use try-except.
For instance, we write
try:
f()
except:
pass
to call function f
in the try
block.
And any exceptions raised in f
will be caught in the except
block.
We just add pass
in the except
block to make it an empty block.
Conclusion
To properly ignore exceptions with Python, we can use try-except.