๐ŸŒ
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
๐ŸŒ
Refactoring.Guru
refactoring.guru โ€บ home โ€บ design patterns โ€บ creational patterns
Abstract Factory
January 1, 2026 - These methods must return abstract product types represented by the interfaces we extracted previously: Chair, Sofa, CoffeeTable and so on. Each concrete factory corresponds to a specific product variant. Now, how about the product variants? For each variant of a product family, we create a separate factory class based on the AbstractFactory interface.
Discussions

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
python - Define an abstract method but require a subclass implementation - Stack Overflow
Restating in another, maybe better way, I'm looking of a way to partially implement a Parent.method but require that there is a Subclass.method also, which uses and adds to the partial Parent.method implementation. I would like to partially define an abstract class method, but still require ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
Simple explanation of abstract classes?
Ugh, I hate the use of that term "abstract" when explaining classes to beginners (like me). I guess correct class usage requires abstraction, but the abstraction is the fact that we're thinking in classes instead of functions/instances. This article , among many, helped me understand classes, what they are, and their related methods (like __init__) better. When you go from defining things like this: Each Modern Table: Has 4 legs Has a plastic top Each IKEA Table: Has 4 legs Looks shitty Each Quality Table: Has 4 legs is expensive To: Each Table has 4 legs Modern Table is a specific kind of table and has a plastic top IKEA Table is a specific kind of table and looks shitty Quality Table is a specific kind of table and is expensive. If we know that each and every table has four legs, we can create a Table(Object) with self.legs = 4, and every KindofTable(Table) will also have (inherit) this atrribute and value, saving us the need to specify this for each kind of table. The abstraction here is that even though we defined how every table looks like, we don't yet have an actual table until we create/instantiate a new table: # Table(Object) --> Not a table! our_table = Table() # a table, has 4 legs our_table2 = Table() # a table, has 4 legs our_table3 = KindofTable() # a table, has 4 legs (because KindofTable(Table) inherits from Table(Object) and other attributes that are specific to it A self-explaining disclaimer is in my flair. More on reddit.com
๐ŸŒ r/learnpython
8
12
November 24, 2015
Should we use an abstract class when we know a parent class should never be directly accessed?
Why not a non-class module, so instances aren't possible at all? More on reddit.com
๐ŸŒ r/learnpython
9
1
October 6, 2021
๐ŸŒ
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 ...
๐ŸŒ
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 ยท
๐ŸŒ
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.
๐ŸŒ
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.
Call ย  +917738666252
Address ย  Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
๐ŸŒ
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.
๐ŸŒ
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?

Find elsewhere
๐ŸŒ
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:
๐ŸŒ
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
๐ŸŒ
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 ...
๐ŸŒ
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 ......
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ difference-between-abstract-class-and-interface-in-java
Difference Between Abstract Class and Interface in Java - GeeksforGeeks
An abstract class is a class that cannot be instantiated directly. It acts as a base class for other related classes and can contain both abstract and concrete methods.
Published ย  January 21, 2026
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ python_classes.asp
Python Classes
Almost everything in Python is an object, with its properties and methods. A Class is like an object constructor, or a "blueprint" for creating objects.
Top answer
1 of 5
5

Note I do not think that abc inherently solves what I'm looking for.

Actually abc is exactly what you're looking for. Defining an implementation in the base class but decorating it as abstract requires deriving classes to redefine it. Of course this has the side effect of preventing you from instantiating the base class, which I assume is OK in your use case.

import abc


# inheritance from abc.ABC is important, as otherwise the decorators don't do anything
class AbstractClass(abc.ABC):
    @abc.abstractmethod
    def amethod(self):
        # some code that should always be executed here
        print("Base implementation")


class ActualClass(AbstractClass):
    # will return TypeError: Can't instantiate abstract class ActualClass with abstract methods amethod if not redefined
    def amethod(self):
        # Actual class code
        print("Actual implementation")

        # And execute the super class code. (only one super class so less confusing)
        super().amethod()


a = ActualClass()
a.amethod()
2 of 5
1

Test like this?

class AbstractClass(object):
    def amethod(self):
        # some code that should always be executed here
        print(" AbstractClass.amethod()")

        # But, since we're the "abstract" class
        # force implementation through subclassing
        if self.__class__ == AbstractClass:
            raise NotImplementedError

class ActualClass(AbstractClass):
    def amethod(self):
        # Actual class code
        print(" ActualClass.amethod()")

        # And execute the super class code.
        super(ActualClass, self).amethod()


#a = AbstractClass()
#a.amethod()

b = ActualClass()
b.amethod()
๐ŸŒ
Ramblings
clamytoe.github.io โ€บ articles โ€บ 2020 โ€บ Mar โ€บ 12 โ€บ testing-abcs-with-abstract-methods-with-pytest
Testing abc's with abstract methods with pytest
March 12, 2020 - class Site(ABC): web: Web def find_table(self, loc: int = 0) -> str: return self.web.soup.find_all("table")[loc] @abstractmethod def parse_rows(self, table: Soup) -> List[Any]: pass @abstractmethod def polls(self, table: int = 0) -> List[Any]: pass @abstractmethod def stats(self, loc: int = 0): pass
๐ŸŒ
Wikipedia
en.wikipedia.org โ€บ wiki โ€บ Abstract_data_type
Abstract data type - Wikipedia
2 weeks ago - When a class is used as a type, it is an abstract type that refers to a hidden representation. In this model, an ADT is typically implemented as a class, and each instance of the ADT is usually an object of that class. The module's interface typically declares the constructors as ordinary procedures, and most of the other ADT operations as methods ...
๐ŸŒ
Oboe
oboe.com โ€บ home โ€บ intermediate python application design โ€บ inheritance and polymorphism - intermediate python application design
Inheritance and Polymorphism - Intermediate Python Application Design - Intermediate Python Application Design
2 weeks ago - It can define methods that any child class is required to implement. You cannot create an instance of an ABC itself; it only exists to be inherited from. from abc import ABC, abstractmethod class MediaFile(ABC): # Inherit from ABC def __init__(self, ...
๐ŸŒ
Python documentation
docs.python.org โ€บ 3 โ€บ reference โ€บ datamodel.html
3. Data model โ€” Python 3.14.3 documentation
For instance, when C is a class which contains a definition for a function f(), and x is an instance of C, calling x.f(1) is equivalent to calling C.f(x, 1). When an instance method object is derived from a classmethod object, the โ€œclass instanceโ€ stored in __self__ will actually be the class itself, so that calling either x.f(1) or C.f(1) is equivalent to calling f(C,1) where f is the underlying function.