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
🌐
GeeksforGeeks
geeksforgeeks.org › python › abstract-classes-in-python
Abstract Classes in Python - GeeksforGeeks
Python provides the abc module to define ABCs and enforce the implementation of abstract methods in subclasses. Example: This example shows an abstract class Animal with an abstract method sound() and a concrete subclass Dog that implements it.
Published   September 3, 2025
🌐
Python
docs.python.org › 3 › library › abc.html
abc — Abstract Base Classes
This special case is deprecated, as the property() decorator is now correctly identified as abstract when applied to an abstract method: class C(ABC): @property @abstractmethod def my_abstract_property(self): ... The above example defines a read-only property; you can also define a read-write abstract property by appropriately marking one or more of the underlying methods as abstract:
🌐
DataCamp
datacamp.com › tutorial › python-abstract-classes
Python Abstract Classes: A Comprehensive Guide with Examples | DataCamp
January 22, 2025 - You create an abstract class called Shape that says every shape must have an area() method. But Shape doesn’t define how area() works—because the formula depends on the type of shape. Each specific shape (like a Circle or Rectangle) inherits from Shape and provides its own version of area(). If you're looking to learn more about key Python concepts, you can enroll in our Intermediate Object-Oriented Programming in Python course.
🌐
Python Course
python-course.eu › oop › the-abc-of-abstract-base-classes.php
20. The 'ABC' of Abstract Base Classes | OOP | python-course.eu
------------------------------... 4 x = DoAdd42(4) TypeError: Can't instantiate abstract class DoAdd42 with abstract methods do_something · We will do it the correct way in the following example, in which we define two classes inheriting from our abstract class...
🌐
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
🌐
Scaler
scaler.com › home › topics › abstract class in python
Abstract Class in Python - Scaler Topics
April 9, 2024 - For example, in Python we do not know how the sort() function of the list class works, we just use this function, and it sorts a list for us. We cannot create an abstract class in Python directly. However, Python does provide a module that allows us to define abstract classes. The module we can use to create an abstract class in Python is abc(abstract base class) module. Abstract methods ...
🌐
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.
Find elsewhere
🌐
TutorialsPoint
tutorialspoint.com › abstract-base-classes-in-python-abc
Python - Abstract Base Classes
ABC Class: This class from Python's Abstract Base Classes (ABCs) module serves as the foundation for creating abstract base classes. Any class derived from ABC is considered an abstract base class. 'abstractmethod' Decorator: This decorator from the abc module is used to declare methods as abstract.
🌐
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 ...
By mastering abstract classes and abstract methods, you'll be able to easily add new types of derived classes without modifying existing code — a key principle of software design. For example, consider the following implementation, where you adhere to the defined interface without any modifications to the existing Shape class:
🌐
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 - Python’s abc (Abstract Base Classes) module provides the infrastructure for creating abstract classes. 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 · In this example, AbstractClass is an abstract class containing an abstract method abstract_method.
🌐
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 · From the above example, we can understand that an abstract class is the one which does not have implementation.
🌐
The Teclado Blog
blog.teclado.com › python-abc-abstract-base-classes
How to Write Cleaner Python Code Using Abstract Classes
October 26, 2022 - We use @abstractmethod to define a method in the abstract base class and combination of @property and @abstractmethod in order to define an abstract property. I hope you learnt something new today! If you're looking to upgrade your Python skills even further, check out our Complete Python Course.
🌐
Python Tutorial
pythontutorial.net › home › python oop › python abstract classes
Python Abstract Class
March 31, 2025 - from abc import ABC, abstractmethod class AbstractClassName(ABC): @abstractmethod def abstract_method_name(self): pass Code language: Python (python)
🌐
Towards Data Science
towardsdatascience.com › home › latest › how to use abstract classes in python
How to Use Abstract Classes in Python | Towards Data Science
January 21, 2025 - In the code above, we create a new abstract class called BasicPokemon. We indicate that the method main_attack is an abstract method by using the decorator abstractmethod, which means we expect this to be implemented in every subclass of ...
🌐
Real Python
realpython.com › ref › glossary › abstract-method
abstract method | Python Glossary – Real Python
>>> from abc import ABC, abstractmethod >>> class Animal(ABC): ... @abstractmethod ... def speak(self): ... """Return the sound this animal makes.""" ... ... ... >>> Animal() Traceback (most recent call last): ... TypeError: Can't instantiate ...
🌐
30 Days Coding
30dayscoding.com › blog › abstract-methods-in-python
Unlocking the Power of Abstract Methods in Python
To use an abstract method, you need to create a subclass that inherits from the abstract class and implements the abstract method. Here is an example: ```python from abc import ABC, abstractmethod
🌐
Python Module of the Week
pymotw.com › 2 › abc
abc – Abstract Base Classes - Python Module of the Week
Since ABCWithConcreteImplementation is an abstract base class, it isn’t possible to instantiate it to use it directly. Subclasses must provide an override for retrieve_values(), and in this case the concrete class massages the data before returning it at all. $ python abc_concrete_method.py base class reading data subclass sorting data ['line one', 'line three', 'line two']
🌐
Real Python
realpython.com › ref › glossary › abstract-base-class
abstract base class (ABC) | Python Glossary – Real Python
Dog is a concrete class that inherits from Animal and implements the .speak() abstract method. It inherits the .jump() method from Animal. ... In this tutorial, you'll explore how to use a Python interface. You'll come to understand why interfaces are so useful and learn how to implement formal and informal interfaces in Python.