Except Block in Python

 

Except Block in Python



Named Except Block

This block can handle matching to the exception class name it is defined for.

By this we can have different handling for different types of exceptions

Syntax :

except exception_class_name1 :

exception handling statement(s)

except exception_class_name2 :

exception handling statement(s)




Default Except Block

This block can handle all types of exception, but provide a single solution for all.

Syntax :

except :

exception handling statement(s)


NOTE : if you have multiple statements in try block and exception occurs in first statement or any other statement apart then last statement, from there try will handover exception to except block and will skip rest of the statement(s) execution under try block .




Comments

My photo
Techno Xpresss
Bangalore, Karnataka, India