Exceptions in Python

Exceptions in Python: Handling Errors with try and except, Raising Your Own Exceptions.

Updated

  1. Handling Errors with try and except (Apprentice): An exception is Python's report of an error while a program runs, and try and except let a program catch the one it expects, such as the ValueError from turning "two" into a number, with else for what runs when nothing went wrong and finally for what runs every time.
  2. Raising Your Own Exceptions (Journeyman): A function that's handed a value that makes no sense should refuse it with raise and a message that says what was wrong, can name its own kind of error with a small exception class, and raises rather than returning None when carrying on would give a wrong answer.