I've used this before in cases where it was possible to have the concrete implementation, but I wanted to force subclass implementers to consider if that implementation is appropriate for them.

One specific example: I was implementing an abstract base class with an abstract factory method so subclasses can define their own __init__ function but have a common interface to create them. It was something like

class Foo(ABC):
    def __init__(self, a, b, c):
        self.a = a
        self.b = b
        self.c = c

    @classmethod
    @abstractmethod
    def from_args(cls, a, b, c) -> "Foo":
        return cls(a, b, c)

Subclasses usually only need a subset of the arguments. When testing, it's cumbersome to access the framework which actually uses this factory method, so it's likely someone will forget to implement the from_args factory function since it wouldn't come up in their usual testing. Making it an abstractmethod would make it impossible to initialize the class without first implementing it, and will definitely come up during normal testing.

Answer from rchome on Stack Overflow
Top answer
1 of 2
7

I've used this before in cases where it was possible to have the concrete implementation, but I wanted to force subclass implementers to consider if that implementation is appropriate for them.

One specific example: I was implementing an abstract base class with an abstract factory method so subclasses can define their own __init__ function but have a common interface to create them. It was something like

class Foo(ABC):
    def __init__(self, a, b, c):
        self.a = a
        self.b = b
        self.c = c

    @classmethod
    @abstractmethod
    def from_args(cls, a, b, c) -> "Foo":
        return cls(a, b, c)

Subclasses usually only need a subset of the arguments. When testing, it's cumbersome to access the framework which actually uses this factory method, so it's likely someone will forget to implement the from_args factory function since it wouldn't come up in their usual testing. Making it an abstractmethod would make it impossible to initialize the class without first implementing it, and will definitely come up during normal testing.

2 of 2
4

The short answer is: Yes.

As described in the Python Documentation of abc:

The abstract methods can be called using any of the normal ‘super’ call mechanisms

PEP3119 also discussed this behavior, and explained it can be useful in the super-call:

Unlike Java’s abstract methods or C++’s pure abstract methods, abstract methods as defined here may have an implementation. This implementation can be called via the super mechanism from the class that overrides it. This could be useful as an end-point for a super-call in framework using cooperative multiple-inheritance [7], [8].

Actually, what the @abstractmethod decorator all do is setting the function's __isabstractmethod__ attribute to True (you can see the implementation code here). And the cooperation of both ABC and @abstractmethod can prevent the instantiation of an abstract class.

So, you can do whatever a normal method can do in an abstract method.

🌐
Python
docs.python.org › 3 › library › abc.html
abc — Abstract Base Classes
The ABC MyIterable defines the standard iterable method, __iter__(), as an abstract method. The implementation given here can still be called from subclasses.
Discussions

inheritance - Abstract methods in Python - Stack Overflow
Periodically I implement something using them and am amazed at my own cleverness, very shortly afterwards I find myself completely confused by my own cleverness (this may well just be a personal limitation though). Another way of doing this (should be in the python std libs if you ask me) is to make a decorator. def abstractmethod(method): """ An @abstractmethod member fn decorator. (put this in some library somewhere for reuse). """ def default... More on stackoverflow.com
🌐 stackoverflow.com
AbstractMethods and NotImplementedError
Are there any experts on the use of ABCs and abstractmethod who could weigh in on a documentation issue please? The documentation for the exception says that abstract methods should raise NotImplementedError. Obviously this is not mandatory. Abstract methods can have default implementations. More on discuss.python.org
🌐 discuss.python.org
0
1
December 22, 2022
Implement Base classes as AbstractBaseClasses
Python supports abstract base classes (ABCs) through the abc module in stdlib. This allows you to mark methods that should be overloaded by child classes as such by using the @abstractmethod decora... More on github.com
🌐 github.com
2
November 8, 2019
Issue with abstract methods that have an optional parameter

This has nothing to do with abstract classes. Method parameters are still bivariant so this type checks: see here

The typechecker considers it ok for the parameter in the parent to be less specific than the inheriting child, even though it is unsound.

It's by design because the sound alternative would be a significant inconvenience for array interfaces.

More on reddit.com
🌐 r/typescript
9
12
March 20, 2017
🌐
Reddit
reddit.com › r/python › what's the point of abstract classes if they don't enforce method signatures?
r/Python on Reddit: What's the point of abstract classes if they don't enforce method signatures?
December 18, 2016 -

I was surprised to see the Python abstract classes don't enforce anything except the override and method name. I can see why in Python enforcing parameter data-types would probably not work, but the number of parameters and parameter names ought to be enforced.

I've always thought the point of abstract classes was to ensure that any inheritor of the class would would work with existing code to run the abstract methods defined in the super class. The whole point was to enforce method signatures.

It seems to me that Python's implantation of abstract classes has very little utility. Does anyone even use them? What for?

🌐
Python
peps.python.org › pep-3119
PEP 3119 – Introducing Abstract Base Classes | peps.python.org
The default concrete implementation returns a “view” on the key set (meaning if the underlying mapping is modified, the view’s value changes correspondingly); subclasses are not required to return a view but they should return a Set.
🌐
Real Python
realpython.com › ref › glossary › abstract-method
abstract method | Python Glossary – Real Python
If any abstract methods remain unimplemented in a subclass, Python prevents you from instantiating that class, helping you catch design mistakes early. You can still provide a default implementation inside an abstract method.
🌐
YouTube
youtube.com › codetube
python abstract method with default implementation - YouTube
Download this code from https://codegive.com In object-oriented programming, an abstract method is a method that is declared in an abstract class but has no ...
Published   December 13, 2023
Views   15
Find elsewhere
🌐
The Teclado Blog
blog.teclado.com › python-abc-abstract-base-classes
How to Write Cleaner Python Code Using Abstract Classes
October 26, 2022 - We could also use default arguments, you can read about those here. We may also want to create abstract properties and force our subclass to implement those properties. This could be done by using @property decorator along with @absctractmethod.
🌐
DataCamp
datacamp.com › tutorial › python-abstract-classes
Python Abstract Classes: A Comprehensive Guide with Examples | DataCamp
January 22, 2025 - Abstract classes are useful when ... code predictability and makes maintenance easier. If every method can have a default implementation, do not use abstract classes....
🌐
Python.org
discuss.python.org › python help
AbstractMethods and NotImplementedError - Python Help - Discussions on Python.org
December 22, 2022 - The documentation for the exception says that abstract methods should raise NotImplementedError. Obviously this is not mandatory. Abstract methods can have default implementations.
🌐
GeeksforGeeks
geeksforgeeks.org › python › abstract-classes-in-python
Abstract Classes in Python - GeeksforGeeks
If you try to instantiate Animal directly, Python will raise a TypeError since the method is not implemented. Concrete methods are methods that have full implementations in an abstract class. These methods can be inherited by subclasses and ...
Published   September 3, 2025
🌐
JetBrains
jetbrains.com › help › pycharm › implementing-methods-of-an-interface.html
Implement methods of an abstract class | PyCharm Documentation
April 10, 2025 - It's possible to implement methods ... NotImplementedError. By default, the classes that do not implement the abstract methods are detected by the code inspection and highlighted in the editor....
🌐
Luis Llamas
luisllamas.es › inicio › cursos › curso python
How to Use Abstract Classes in Python
November 20, 2024 - In this example, Dog and Cat are subclasses of Animal that implement the abstract method make_sound. An abstract class can have both abstract methods and concrete methods. Concrete methods provide a default implementation that can be inherited ...
🌐
Zero To Mastery
zerotomastery.io › blog › abstract-classes-in-python
Beginner’s Guide to Abstract Classes in Python | Zero To Mastery
June 23, 2025 - If there's a reasonable default that works for most cases, define it in the base class and let subclasses override it only if needed. This one’s a bit sneaky because it’s true that Python ...
🌐
CopyProgramming
copyprogramming.com › howto › python-abstract-method-with-default-implementation-python
Python: Python: Defining Abstract Methods with Default Implementations
March 20, 2023 - Using the super() Method with Python's Abstract Method Default Logic could be rephrased as Python's Default Logic for Abstract Methods and the super() Method, Default Argument in Python Typing's Abstract Method could be the rephrased MSDTHOT, Transferring the execution of an undefined method ...
🌐
EDUCBA
educba.com › home › software development › software development tutorials › python tutorial › abstract class in python
Abstract Class in Python |Learn How do Abstract Classes work in Python?
April 17, 2023 - The @abstractmethod decorator has to be imported from the python built-in library called abc. Python does not have abstract classes by default, but it has a module or library which forms the base for defining Abstract Base classes (ABC) and ...
Address   Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
🌐
Restack
restack.io › p › python-abstract-class-default-implementation-answer
Python Abstract Class Default Implementation | Restackio
April 30, 2025 - In Python, abstract classes can provide default implementations for methods, allowing subclasses to inherit these methods without needing to override them unless necessary.
🌐
Python Course
python-course.eu › oop › the-abc-of-abstract-base-classes.php
20. The 'ABC' of Abstract Base Classes | OOP | python-course.eu
We will define now a subclass using the previously defined abstract class. You will notice that we haven't implemented the do_something method, even though we are required to implement it, because this method is decorated as an abstract method with the decorator "abstractmethod".
🌐
GitHub
github.com › mbakker7 › timml › issues › 31
Implement Base classes as AbstractBaseClasses · Issue #31 · mbakker7/timml
November 8, 2019 - Python supports abstract base classes (ABCs) through the abc module in stdlib. This allows you to mark methods that should be overloaded by child classes as such by using the @abstractmethod decora...
Author   Hugovdberg
🌐
Quora
quora.com › Why-can-t-abstract-classes-have-default-methods-even-though-an-interface-can
Why can’t abstract classes have default methods (even though an interface can)? - Quora
Answer (1 of 4): All non-abstract methods in an abstract class are inherited by its sub-classes. So they are already kind of “default” methods if that’s what you mean. On the other hand, you have to understand the purpose of default methods ...