Before abc was introduced you would see this frequently.

class Base(object):
    def go(self):
        raise NotImplementedError("Please Implement this method")


class Specialized(Base):
    def go(self):
        print "Consider me implemented"
Answer from kevpie on Stack Overflow
🌐
Dot Net Tutorials
dotnettutorials.net › home › abstract classes in python
Abstract classes in Python with Examples - Dot Net Tutorials
August 5, 2020 - Abstract methods, in python, are declared by using @abstractmethod decorator. For better understanding, please have a look at the bellow image. Method ‘one’ is abstract method. Method ‘two’ is non-abstract method. Since one abstract method is present in class ‘Demo’, it is called Abstract class
🌐
GitHub
github.com › python › typing › issues › 577
Abstract class methods? · Issue #577 · python/typing
August 1, 2018 - This might not be the right place to put this, but is there any interest in adding a decorator for abstract class methods? (And potentially supporting it in MyPy?) Currently, annotating a method with both @abstractmethod and @classmethod...
Author   sid-kap
Discussions

inheritance - Abstract methods in Python - Stack Overflow
Since python isn't compiled, you ... of abstract classes. ... Also a very good application for unit testing. As Python is not compiled, I don't begin to trust code until I've unit tested it. ... Before abc was introduced you would see this frequently. class Base(object): def go(self): raise NotImplementedError("Please Implement this method") class ... More on stackoverflow.com
🌐 stackoverflow.com
What's the point of ABC & @abstractmethod
So your examples are a bit problematic because you would never use @abstractmethod in that situation. In your example there is no reason not to define the function only in the parent class--the parent knows everything it needs in order to execute the function, and the children don't change the execution at all. Also, Abs is a terrible name for a class. @abstractmethod is for when you: Require all children to have a method Don't have enough information to define that method in the parent Essentially, it "requires" child classes to define this method. This allows you to include the method in your parent interface so you can document it but raises a sensible error if the child doesn't re-define it. This is mostly useful for parent classes that will never have direct instances--only instances of subclasses. Consider designing a shooter game like Doom or Quake. You might represent various objects and enemies as class instances. To keep the game synced, every clock tick all the objects need to "update" themselves. Enemies might move around, lights might blink, and items might recharge. They all need to do something, but what they do is completely unique to each class. In a case like this, you might define the update() method in the parent Object class. This is mostly a convenience feature--you can write the same code perfectly well without it. However, it allows you to refer to all objects collectively (isinstance(o, Object)) through the parent class, and still ensure that update() exists, even though the parent doesn't know what to do with it. You could easily define update() in the parent and have it do nothing, but this prevents errors from being raised if you call this on a child class that hasn't re-defined the method. More on reddit.com
🌐 r/learnpython
11
14
July 27, 2021
What's the point of abstract classes if they don't enforce method signatures?
Typically abstract classes are only used for libraries, where the end user might want to provide their own version of a class. The "abstract" concept is mainly to help IDE's/linters so that when someone implements the class, they can see what needs to be implemented. That being said, abstract classes are mainly just to help others, they should never be used to check that an object is an instance of the abstract class. This is python, not a strong OO language, and as such, you shouldn't enforce any strong OO. Python is about duck typing. The typical python rule is: "we are all adults here", which typically means "guidelines" and not enforcement. The method signatures for ABC's are the same way. Someone probably should match the function signature, but if they don't want to, they shouldn't have to. More on reddit.com
🌐 r/Python
14
4
December 18, 2016
Why do we need abstract classes and methods in python?

https://www.reddit.com/r/learnpython/comments/vidjcj/what_on_earth_is_the_point_of_abstract_classes/

More on reddit.com
🌐 r/learnpython
1
1
January 18, 2021
🌐
Python
docs.python.org › 3 › library › abc.html
abc — Abstract Base Classes
Metaclass for defining Abstract Base Classes (ABCs). Use this metaclass to create an ABC. An ABC can be subclassed directly, and then acts as a mix-in class. You can also register unrelated concrete classes (even built-in classes) and unrelated ABCs as “virtual subclasses” – these and their descendants will be considered subclasses of the registering ABC by the built-in issubclass() function, but the registering ABC won’t show up in their MRO (Method Resolution Order) nor will method implementations defined by the registering ABC be callable (not even via super()).
🌐
Python Course
python-course.eu › oop › the-abc-of-abstract-base-classes.php
20. The 'ABC' of Abstract Base Classes | OOP | python-course.eu
Abstract classes are classes that contain one or more abstract methods. An abstract method is a method that is declared, but contains no implementation.
🌐
Reddit
reddit.com › r/learnpython › what's the point of abc & @abstractmethod
r/learnpython on Reddit: What's the point of ABC & @abstractmethod
July 27, 2021 -

Hello. In this first example, I have a short and straightforward code w/ a class for interface. It doesn't inherit from ABC and doesn't have any abstract methods.

class Abs():
    def __init__(self, name, age):
        self.name = name
        self.age = age
        
    def go_to(self):
        return f"{self.name} is going to {self.place}."
        
class Teacher(Abs):
    place = "work"

class Student(Abs):
    place = "school"
    
t1 = Teacher("James", 56)
s1 = Student("Tim", 15)

print(t1.go_to())
print(s1.go_to())

In this second example, it's the exact opposite.

from abc import ABC, abstractmethod

class Abs(ABC):
    def __init__(self, name, age):
        self.name = name
        self.age = age
        
    @abstractmethod
    def go_to(self):
        ...
        
class Teacher(Abs):
    place = "work"
    
    def go_to(self):
        return f"{self.name} is going to {self.place}."

class Student(Abs):
    place = "school"
    
    def go_to(self):
        return f"{self.name} is going to {self.place}."
    
t1 = Teacher("James", 56)
s1 = Student("Tim", 15)

print(t1.go_to())
print(s1.go_to())

Both examples have the same output. In the tutorials/articles I've read, most times the second example is preferred. In the abstract class, abstract methods get defined and decorated, and then in the inheriting classes they all get redefined with the rest of the logic. What's the point of creating a class w/ abstract methods which later on we redefine? What issue does that solve? Why not just proceed as in the first example - simple, less code, one parent class for the interface, if we need to add other details, we do so in the base class once and handle the extra logic with that additional info there. Doesn't the first code present a better example of loose coupling - just one connection between parent and child classes, where in the second code, we get connections between parent/child in every method that we redefine? I feel like I'm missing something, because to me, the second example is much more spaghetti-like. If anyone can explain why it's a good practice to redefine abstract methods that would be nice. Also, is it a bad practice to write code as in the first example, w/o ABC+@abstractmethod in the parent class?
Thanks.

Top answer
1 of 5
10
So your examples are a bit problematic because you would never use @abstractmethod in that situation. In your example there is no reason not to define the function only in the parent class--the parent knows everything it needs in order to execute the function, and the children don't change the execution at all. Also, Abs is a terrible name for a class. @abstractmethod is for when you: Require all children to have a method Don't have enough information to define that method in the parent Essentially, it "requires" child classes to define this method. This allows you to include the method in your parent interface so you can document it but raises a sensible error if the child doesn't re-define it. This is mostly useful for parent classes that will never have direct instances--only instances of subclasses. Consider designing a shooter game like Doom or Quake. You might represent various objects and enemies as class instances. To keep the game synced, every clock tick all the objects need to "update" themselves. Enemies might move around, lights might blink, and items might recharge. They all need to do something, but what they do is completely unique to each class. In a case like this, you might define the update() method in the parent Object class. This is mostly a convenience feature--you can write the same code perfectly well without it. However, it allows you to refer to all objects collectively (isinstance(o, Object)) through the parent class, and still ensure that update() exists, even though the parent doesn't know what to do with it. You could easily define update() in the parent and have it do nothing, but this prevents errors from being raised if you call this on a child class that hasn't re-defined the method.
2 of 5
3
let's imagine a List interface - we'll have the operations of append and pop class List(ABC): @abstractmethod def append(self, val): pass @abstractmethod def pop(self): pass now we could create class LinkedList(List) and class ArrayList(List) where we'd implement the methods for both of the list types the reason for using ABC and @abstractmethod is because it doesn't make sense to be able to be able to instantiate a List - that doesn't have an implementation. it only describes what behaviour an implementation should have to provide. think of it as providing a contract by which all users of an object know what behaviour to expect abstract classes and methods are more useful in languages such as java where you can't rely on duck typing void doThing(List list) this would take any subclass of List and be checked at compile time to have the expected methods of append and pop
🌐
Medium
medium.com › @abhishekjainindore24 › embracing-abstraction-a-dive-into-abstract-classes-in-python-0faf6d83948d
Embracing Abstraction: A Dive into Abstract Classes in Python | by Abhishek Jain | Medium
September 8, 2024 - The ABC (Abstract Base Class) meta-class, along with the @abstractmethod decorator, facilitates the definition of abstract methods. from abc import ABC, abstractmethod class AbstractClass(ABC): @abstractmethod def abstract_method(self): pass
Find elsewhere
🌐
Medium
medium.com › @prashampahadiya9228 › abstract-classes-and-abstract-methods-in-python-e632ea34bc79
Abstract Classes and Abstract Methods in Python | by Prasham Pahadiya | Medium
May 31, 2024 - Abstract Classes An abstract class is a class that is meant to be subclassed but not instantiated directly. It can include one or more abstract methods. In Python, abstract classes are created using the `abc` module, specifically the `ABC` class.
🌐
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 - To consider any class as an abstract class, the class has to inherit ABC metaclass from the python built-in abc module. abc module imports the ABC metaclass. Abstract methods are the methods that are declared without any implementations.
Address   Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
🌐
DataCamp
datacamp.com › tutorial › python-abstract-classes
Python Abstract Classes: A Comprehensive Guide with Examples | DataCamp
January 22, 2025 - If you're new to Python, you can learn how to work with modules and packages, work with built-in data types, and write custom functions with our skill track. An abstract class is like a template for other classes. It defines methods that must be included in any class that inherits from it, but it doesn’t provide the actual code for those methods.
🌐
CodeSignal
codesignal.com › learn › courses › revisiting-oop-concepts-in-python › lessons › understanding-abstract-classes-and-abstract-methods-in-python
Understanding Abstract Classes and Abstract Methods in ...
Think of it as a blueprint for other classes. It often includes one or more abstract methods. A class that inherits from an abstract class must implement all its abstract methods. In Python, the abc (Abstract Base Classes) module provides tools for defining abstract base classes.
🌐
Python Lobby
pythonlobby.com › home › abstract class and abstract method in python programming
Abstract Class and Abstract Method in Python Programming - Python Lobby
April 19, 2021 - Abstract Class and Abstract Method ... is the class that contains one or more abstract methods. These types of classes in python are called abstract classes. Abstract methods are the methods that have an empty body or we can ...
🌐
Tutlane
tutlane.com › tutorial › python › python-abstract-classes
Python Abstract Classes - Tutlane
To create abstract methods, you need to create methods by decorating with the @abstractmethod attribute. Following is the example of creating the abstract classes in python.
🌐
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?

🌐
GeeksforGeeks
geeksforgeeks.org › python › abstract-classes-in-python
Abstract Classes in Python - GeeksforGeeks
Abstract classes allow us to define methods that must be implemented by subclasses, ensuring a consistent interface while still allowing the subclasses to provide specific implementations.
Published   September 3, 2025
🌐
Real Python
realpython.com › ref › glossary › abstract-method
abstract method | Python Glossary – Real Python
An abstract method is a method in an abstract base class (ABC) that you mark as abstract rather than making it fully concrete. You mark abstract methods with the @abstractmethod decorator from the abc module.
🌐
Python documentation
docs.python.org › 3 › library › stdtypes.html
Built-in Types — Python 3.14.3 documentation
2 weeks ago - The int type implements the numbers.Integral abstract base class. In addition, it provides a few more methods:
🌐
Python
docs.python.org › 3 › glossary.html
Glossary — Python 3.14.3 documentation
Abstract base classes complement duck-typing by providing a way to define interfaces when other techniques like hasattr() would be clumsy or subtly wrong (for example with magic methods). ABCs introduce virtual subclasses, which are classes that don’t inherit from a class but are still recognized ...
🌐
Pydantic
docs.pydantic.dev › latest › concepts › models
Models - Pydantic Validation
Pydantic models can be used alongside Python's Abstract Base Classes (ABCs). import abc from pydantic import BaseModel class FooBarModel(BaseModel, abc.ABC): a: str b: int @abc.abstractmethod def my_abstract_method(self): pass · Field order affects models in the following ways: field order is preserved in the model JSON Schema ·
🌐
Real Python
realpython.com › ref › glossary › abstract-base-class
abstract base class (ABC) | Python Glossary – Real Python
In Python, an abstract base class ... a common interface for a group of related classes. ABCs allow you to define methods that must be created within any subclasses ......