
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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
Handle Exception Thrown by Except Clause in Python
We have a scenario in which code in except clause itself raises exception. In given code, we can handle the exception raised by except clause as follows.
Example
import sys try: a = john except: try: 4/0 except: print sys.exc_info()
Output
We get the following output
"C:/Users/TutorialsPoint1/~.py" (<type 'exceptions.ZeroDivisionError'>, ZeroDivisionError('integer division or modulo by zero',), <traceback object at 0x0000000002BD4B88>)
Advertisements