How to Handle Exceptions in Python

Click for: original source

Monty Shokeen wrote neat article about handling exceptions in Python programming language. It is very common to encounter errors during the execution of a program. Two common kinds of errors that you may have to deal with are syntax errors and exceptions.

Exceptions occur during the execution of a program when something unexpected happens. For example, let’s say you are asking the user to input a number in order to perform a division.

In this tutorial, you will learn how to properly handle and raise exceptions in Python. Article describes many types of exceptions, including:

  • NameError
  • TypeError
  • ValueError
  • ZeroDivisionError
  • NotImplementedError
  • FileNotFoundError

Code examples, including ones with more complex multiple exceptions, are present. Good read.

[Read More]

Tags python programming oop