From the course: Python Object-Oriented Programming

Unlock the full course today

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

Interfaces

Interfaces

- [Instructor] In this example, we're going to see how to use a combination of multiple inheritance and abstract base classes to implement a type of programming feature called an interface. Some languages like C# and Java provide this feature as a built-in part of the language, but Python doesn't have explicit language support for this feature. You can think of an interface as a kind of promise. By implementing an interface, a particular class makes a promise, or a contract, as it's often called in software engineering, to provide a certain kind of behavior or capability. So let's open up our interface_start example. And you can see that this is a simplified version of the abstract base class example that we used earlier. So I have my GraphicShape and just my Circle. Suppose we wanted our shape objects to be able to provide the ability to represent themselves as JSON. Now we could just make that a part of the GraphicShape…

Contents