🌐
Python
docs.python.org › 3 › library › abc.html
abc — Abstract Base Classes
This module provides the infrastructure for defining abstract base classes (ABCs) in Python, as outlined in PEP 3119; see the PEP for why this was added to Python.
🌐
Python Course
python-course.eu › oop › the-abc-of-abstract-base-classes.php
20. The 'ABC' of Abstract Base Classes | OOP | python-course.eu
from abc import ABC, abstractmethod class AbstractClassExample(ABC): def __init__(self, value): self.value = value super().__init__() @abstractmethod def do_something(self): pass
🌐
W3Schools
w3schools.com › python › ref_module_abc.asp
Python abc Module
Python Examples Python Compiler ... Python Certificate Python Training · ❮ Standard Library Modules · Define an abstract base class and implement it: from abc import ABC, abstractmethod class Shape(ABC): @abstractmethod def ...
🌐
Earthly
earthly.dev › blog › abstract-base-classes-python
Abstract Base Classes in Python - Earthly Blog
July 19, 2023 - Let’s consider the Shape ABC we defined in the interfaces section, we have different shapes such as circles, rectangles, and triangles. Each shape has an area and a perimeter, so any class that inherits from Shape must implement both the area and perimeter methods. For example, we can define a Square concrete class that will inherit from Shape and provide implementations for both methods. # shape.py class Square(Shape): def __init__(self, side_length): self.side_length = side_length def area(self): return self.side_length ** 2 def perimeter(self): return 4 * self.side_length
🌐
Geek Python
geekpython.in › abc-in-python
Python's ABC: Understanding the Basics of Abstract Base Classes
October 29, 2023 - Python doesn’t allow creating objects for abstract classes because there is no actual implementation to invoke rather they require subclasses for implementation. ... We got the error stating that we cannot instantiate the abstract class Details with abstract methods called getname and getrole. Just as the abc module allows us to define abstract methods using the @abstractmethod decorator, it also allows us to define abstract properties using the @abstractproperty decorator.
🌐
DEV Community
dev.to › sachingeek › getting-started-with-pythons-abc-4b95
Getting Started With Python's ABC - DEV Community
April 6, 2023 - Python is not a fully object-oriented programming language but it supports the features like abstract classes and abstraction. We cannot create abstract classes directly in Python, so Python provides a module called abc that provides the infrastructure for defining the base of Abstract Base Classes(ABC).
🌐
DEV Community
dev.to › sarahs › abstract-classes-in-python-55mj
Abstract Classes in Python - DEV Community
December 20, 2023 - ... Title:, a space, and then the current instance's title. Author:, a space, and then the current instance's author. Price:, a space, and then the current instance's price. ... from abc import ABCMeta, abstractmethod class Book(object, ...
🌐
Machine Learning Plus
machinelearningplus.com › blog › python abcs- the complete guide to abstract base classes
Python ABCs- The Complete Guide to Abstract Base Classes
July 15, 2025 - pythonCopy · # Simple abstract base class for documents class Document(ABC): def __init__(self, title): self.title = title @abstractmethod def save(self): pass @abstractmethod def get_extension(self): pass · The @abstractmethod decorator marks methods that must be implemented by subclasses.
🌐
Medium
medium.com › @mhesty71 › what-i-wish-i-knew-about-init-self-super-and-abstract-classes-7103c8b91128
What I Wish I Knew About __init__, self, super(), and Abstract Classes | by maria siagian | Medium
December 17, 2024 - When I started learning Object-Oriented Programming (OOP) in Python, these concepts — __init__, self, super(), and Abstract Base Classes (ABC)—felt like a puzzle. What exactly does __init__ do? What does self actually represent? What’s the point of super()?
Find elsewhere
🌐
Reddit
reddit.com › r/learnpython › abstract class, how to create it properly?
r/learnpython on Reddit: abstract class, how to create it properly?
March 24, 2024 -

I thought I understood what abstract class means but my professor just commented that it wasn't a abstract class. What I did is essentially this:

first instruction: create an abstract base class with two int attributes then derived another class called Hero with a string attribute which stores the title "hero"

from abc import ABC

class Person(ABC):
def __init__(self, height, speed):
self.height = height
self.speed = speed

def walk(self):
//walk method

from person import Person

class Hero(Person):
def __init__(self, height, speed):
super().__init__(height, speed)
self.person_title = "Hero"

was this the right way to do it?

🌐
CodeFatherTech
codefather.tech › home › blog › create an abstract class in python: a step-by-step guide
Create an Abstract Class in Python: A Step-By-Step Guide
December 8, 2024 - Have you enjoyed this tutorial? We went through quite a lot! We have started by explaining the concept of abstract classes that represent a common interface to create classes that follow well-defined criteria. The name of the Python module we have used in all the examples is ABC (Abstract Base Classes).
🌐
Upgrad
upgrad.com › home › tutorials › software & tech › abstract class in python
Abstract Class in Python | With Example and Interface Comparison
September 12, 2024 - In Python, abstract base classes (ABCs) can also contain concrete methods—methods that are completely implemented in the abstract class itself. The presence of concrete methods in an abstract class allows for a blend of enforced structure and reusable code. ... class Animal(ABC): @abstractmethod def sound(self): pass # Concrete method def describe(self): return "This is an animal." # Create a subclass of Animal class Dog(Animal): def __init__(self, name): self._name = name # Implement the abstract method def sound(self): return "Bark" # Create another subclass of Animal class Cat(Animal): de
🌐
DataCamp
datacamp.com › tutorial › python-abstract-classes
Python Abstract Classes: A Comprehensive Guide with Examples | DataCamp
January 22, 2025 - The ABC class is a built-in Python feature that serves as a fundamental basis for developing abstract classes. You must inherit from ABC to define an abstract class. The class is abstract and cannot be instantiated directly, as indicated by this inheritance.
🌐
GeeksforGeeks
geeksforgeeks.org › abstract-base-class-abc-in-python
Abstract Base Class (abc) in Python - GeeksforGeeks
August 29, 2020 - Python has a module called abc (abstract base class) that offers the necessary tools for crafting an abstract base class. First and foremost, you should understand the ABCMeta metaclass provided by the abstract base class.
🌐
Python.org
discuss.python.org › typing
Enforcing __init__ signature when implementing it as an abstractmethod - Typing - Discussions on Python.org
December 29, 2024 - Hello. I noticed that Pyright doesn’t check the signatures of abstractmethod implementations when the abstractmethod is __init__(). Here’s an example: from abc import ABC, abstractmethod class AbstractA(ABC): @abstractmethod def __init__(self, x: int, y: int): pass @abstractmethod def do_something(self, z: int, u: int): pass class RealA(AbstractA): def __init__(self, x: int): ## No static type checker error self.x = x def do_something...
🌐
CodeConverter
codeconverter.com › articles › python-abstract-class-example
Python Abstract Classes: ABC Module Tutorial | CodeConverter Blog
February 12, 2026 - from abc import ABC, abstractmethod class AbstractClassExample(ABC): @property @abstractmethod def some_property(self): pass class ConcreteClass(AbstractClassExample): def __init__(self): self._some_property = "Hello, world!" @property def some_property(self): return self._some_property @some_property.setter def some_property(self, value): self._some_property = value obj = ConcreteClass() print(obj.some_property) # Output: Hello, world!
🌐
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)
🌐
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']
🌐
Tutorialspoint
tutorialspoint.com › python › python_abstract_base_classes.htm
Python - Abstract Base Classes
When a class inherits from an Abstract Base Class (ABC) it must implement all abstract methods. If it doesn't then Python will raise a TypeError. Here is the example of enforcing implementation of the Abstract Base Class in Python − · class ...