

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to ignore an exception and proceed in Python?
We can run a try-except block without handling the exception the following ways:
try: 1/0 except: pass
and
try: 1/0 except Exception: pass
In the first case, using bare except: is like using except BaseException: which will also catch KeyboardInterrupt, SystemExit and errors like that, which are derived directly from exceptions.BaseException, not exceptions.Exception.
In second case, the things mentioned above won't be caught. The pass statement makes it possible to ignore the exceptions.
- Related Questions & Answers
- How to handle an exception in Python?
- How to raise an exception in Python?
- How to pass argument to an Exception in Python?
- How to pass a variable to an exception in Python?
- Argument of an Exception in Python
- How to capture and print Python exception message?
- How to ignore hidden files using os.listdir() in Python?
- How to handle an exception in JSP?
- How to rethrow an exception in Java?
- Ignore MySQL INSERT IGNORE statement and display an error if duplicate values are inserted in a table
- How do you properly ignore Exceptions in Python?
- How will you explain that an exception is an object in Python?
- How to make an application ignore screen orientation change in Android?
- How do I manually throw/raise an exception in Python?
- How to capture an exception raised by a Python Regular expression?
Advertisements