Created
January 29, 2018 06:25
-
-
Save MishraKhushbu/5c5c712bf147d2fee781513952de67f6 to your computer and use it in GitHub Desktop.
Exception handling 29 Jan 2018
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
What is Exception? | |
An exception is an error that happens during execution of a program. When that | |
error occurs, Python generate an exception that can be handled, which avoids your | |
program to crash. | |
Why use Exception? | |
Exceptions are convenient in many ways for handling errors and special conditions | |
in a program. When you think that you have a code which can produce an error then | |
you can use exception handling | |
Raising an exception breaks current code execution and returns the exception | |
back until it is handled. | |
Some common Exceptions: | |
IOError | |
If the file cannot be opened. | |
ImportError | |
If python cannot find the module | |
ValueError | |
Raised when a built-in operation or function receives an argument that has the | |
right type but an inappropriate value | |
KeyboardInterrupt | |
Raised when the user hits the interrupt key (normally Control-C or Delete) | |
EOFError | |
Raised when one of the built-in functions (input() or raw_input()) hits an | |
end-of-file condition (EOF) without reading any data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment