Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Abstract Method | Polymorphism and Abstraction
In-Depth Python OOP

Abstract Method

Abstract Method is a method that should be redefined in subclasses.

To create an abstract method, you should import the @abstractmethod decorator from the abc library.

Note

Pay attention: decorator is imported without the @ symbol.

The abstract methods should be implemented in subclasses. You can't create a subclass without redefining all abstract methods:

The class Child saved the Abstract Class state because the second_method is not redefined, and the ABC class exists in the inheritance hierarchy.

Note

The abstract classes and methods exist to provide a strict class structure.

question-icon

Abstract Class must have:

Select a few correct answers

Everything was clear?

Section 4. Chapter 6
course content

Course Content

In-Depth Python OOP

Abstract Method

Abstract Method is a method that should be redefined in subclasses.

To create an abstract method, you should import the @abstractmethod decorator from the abc library.

Note

Pay attention: decorator is imported without the @ symbol.

The abstract methods should be implemented in subclasses. You can't create a subclass without redefining all abstract methods:

The class Child saved the Abstract Class state because the second_method is not redefined, and the ABC class exists in the inheritance hierarchy.

Note

The abstract classes and methods exist to provide a strict class structure.

question-icon

Abstract Class must have:

Select a few correct answers

Everything was clear?

Section 4. Chapter 6
some-alt