O'Reilly logo

Python 3 Object Oriented Programming by Dusty Phillips

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Exception hierarchy

We've already encountered many of the most common built-in exceptions, and you'll probably encounter the rest over the course of your regular Python development. As we noticed above, most exceptions are subclasses of the Exception class. But this is not true of all exceptions. Exception itself actually inherits from a class called BaseException (In fact, all exceptions must extend the BaseException class or one of its subclasses). There are two key exceptions, SystemExit and KeyboardInterrupt, that derive directly from BaseException instead of Exception.

SystemExit is an exception that is raised whenever the program exits naturally, typically because we called the sys.exit function somewhere in our code (for example, because ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required