From the course: Python Object-Oriented Programming

Unlock the full course today

Join today to access over 24,500 courses taught by industry experts.

Abstract base classes

Abstract base classes

- [Instructor] Now that we've seen how inheritance works in Python, let's move on to a related topic called abstract base classes. There's a fairly common design pattern in programming where you want to provide a base class that defines a template for other classes to inherit from but with a couple of twists. First, you don't want consumers of your base class to be able to create instances of the base class itself because it's just intended to be a blueprint or a place where you collect some common attributes. And second, you want to enforce the constraint that there are certain methods in the base class that have to be implemented in subclasses. And this is where abstract based classes become really useful. So let's open up abstract_start. And let's imagine that we're building a drawing program that lets the user create different kinds of two dimensional shapes and we want the program to be extensible so that new…

Contents