As mentioned by other here:

Interfaces are not necessary in Python. This is because Python has proper multiple inheritance, and also ducktyping, which means that the places where you must have interfaces in Java, you don't have to have them in Python.

That said, there are still several uses for interfaces. Some of them are covered by Pythons Abstract Base Classes, introduced in Python 2.6. They are useful, if you want to make base classes that cannot be instantiated, but provide a specific interface or part of an implementation.

Another usage is if you somehow want to specify that an object implements a specific interface, and you can use ABC's for that too by subclassing from them. Another way is zope.interface, a module that is a part of the Zope Component Architecture, a really awesomely cool component framework. Here you don't subclass from the interfaces, but instead mark classes (or even instances) as implementing an interface. This can also be used to look up components from a component registry. Supercool!

Answer from Lennart Regebro on Stack Overflow
🌐
Real Python
realpython.com › python-interface
Implementing an Interface in Python – Real Python
February 21, 2024 - Once you’ve imported the abc module, you can directly register a virtual subclass by using the .register() metamethod. In the next example, you register the interface Double as a virtual base class of the built-in __float__ class:
Top answer
1 of 8
272

As mentioned by other here:

Interfaces are not necessary in Python. This is because Python has proper multiple inheritance, and also ducktyping, which means that the places where you must have interfaces in Java, you don't have to have them in Python.

That said, there are still several uses for interfaces. Some of them are covered by Pythons Abstract Base Classes, introduced in Python 2.6. They are useful, if you want to make base classes that cannot be instantiated, but provide a specific interface or part of an implementation.

Another usage is if you somehow want to specify that an object implements a specific interface, and you can use ABC's for that too by subclassing from them. Another way is zope.interface, a module that is a part of the Zope Component Architecture, a really awesomely cool component framework. Here you don't subclass from the interfaces, but instead mark classes (or even instances) as implementing an interface. This can also be used to look up components from a component registry. Supercool!

2 of 8
239

Implementing interfaces with abstract base classes is much simpler in modern Python 3 and they serve a purpose as an interface contract for plug-in extensions.

Create the interface/abstract base class:

from abc import ABC, abstractmethod

class AccountingSystem(ABC):

    @abstractmethod
    def create_purchase_invoice(self, purchase):
        pass

    @abstractmethod
    def create_sale_invoice(self, sale):
        log.debug('Creating sale invoice', sale)

Create a normal subclass and override all abstract methods:

class GizmoAccountingSystem(AccountingSystem):

    def create_purchase_invoice(self, purchase):
        submit_to_gizmo_purchase_service(purchase)

    def create_sale_invoice(self, sale):
        super().create_sale_invoice(sale)
        submit_to_gizmo_sale_service(sale)

You can optionally have common implementation in the abstract methods as in create_sale_invoice(), calling it with super() explicitly in the subclass as above.

Instantiation of a subclass that does not implement all the abstract methods fails:

class IncompleteAccountingSystem(AccountingSystem):
    pass

>>> accounting = IncompleteAccountingSystem()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: Can't instantiate abstract class IncompleteAccountingSystem with abstract methods
create_purchase_invoice, create_sale_invoice

You can also have abstract properties, static and class methods by combining corresponding annotations with @abstractmethod.

Abstract base classes are great for implementing plugin-based systems. All imported subclasses of a class are accessible via __subclasses__(), so if you load all classes from a plugin directory with importlib.import_module() and if they subclass the base class, you have direct access to them via __subclasses__() and you can be sure that the interface contract is enforced for all of them during instantiation.

Here's the plugin loading implementation for the AccountingSystem example above:

...
from importlib import import_module

class AccountingSystem(ABC):

    ...
    _instance = None

    @classmethod
    def instance(cls):
        if not cls._instance:
            module_name = settings.ACCOUNTING_SYSTEM_MODULE_NAME
            import_module(module_name)
            subclasses = cls.__subclasses__()
            if len(subclasses) > 1:
                raise InvalidAccountingSystemError('More than one '
                        f'accounting module: {subclasses}')
            if not subclasses or module_name not in str(subclasses[0]):
                raise InvalidAccountingSystemError('Accounting module '
                        f'{module_name} does not exist or does not '
                        'subclass AccountingSystem')
            cls._instance = subclasses[0]()
        return cls._instance

Then you can access the accounting system plugin object through the AccountingSystem class:

>>> accountingsystem = AccountingSystem.instance()

(Inspired by this PyMOTW-3 post.)

🌐
PyPI
pypi.org › project › python-interface
python-interface
JavaScript is disabled in your browser. Please enable JavaScript to proceed · A required part of this site couldn’t load. This may be due to a browser extension, network issues, or browser settings. Please check your connection, disable any ad blockers, or try using a different browser
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-interface-module
Python-interface module - GeeksforGeeks
March 26, 2020 - In python, interface is defined using python class statements and is a subclass of interface.Interface which is the parent interface for all interfaces. Syntax : class IMyInterface(zope.interface.Interface): # methods and attributes Example ...
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-interface-module
Python-interface module - GeeksforGeeks
March 26, 2020 - In python, interface is defined using python class statements and is a subclass of interface.Interface which is the parent interface for all interfaces. Syntax : class IMyInterface(zope.interface.Interface): # methods and attributes Example ...
🌐
Python Guides
pythonguides.com › python-interface
Understand Python Interfaces - Python Guides
December 1, 2025 - While Python does not have a built-in interface keyword like some other languages, it uses the abc module to create abstract base classes that serve as interfaces.
Find elsewhere
🌐
Tutorialspoint
tutorialspoint.com › python › python_interfaces.htm
Python - Interfaces
In languages like Java and Go, ... have it or any similar keyword. It uses abstract base classes (in short ABC module) and @abstractmethod decorator to create interfaces....
🌐
Readthedocs
python-interface.readthedocs.io
interface — interface 1.4.0 documentation
interface is a library for declaring interfaces and for statically asserting that classes implement those interfaces. It provides stricter semantics than Python’s built-in abc module, and it aims to produce exceptionally useful error messages when interfaces aren’t satisfied.
🌐
Python
docs.python.org › 3 › library › os.html
os — Miscellaneous operating system interfaces
3 weeks ago - Source code: Lib/os.py This module provides a portable way of using operating system dependent functionality. If you just want to read or write a file see open(), if you want to manipulate paths, s...
🌐
Scaler
scaler.com › home › topics › interface in python
Interface in Python - Scaler Topics
June 23, 2024 - They are essential for software engineering and code organization. Interfaces, typically a set of method signatures in object-oriented programming, ensure consistency and manage updates in large applications. While Python uses the abc module, zope.interface offers stricter semantics.
🌐
Upgrad
upgrad.com › home › tutorials › software & tech › interface in python
Interface in Python
January 4, 2026 - In Python, interfaces are defined using abstract base classes (ABCs) provided by the ABC module. Abstract base classes serve as a way to declare the methods that must be implemented by classes that inherit from them.
🌐
Open Textbook
open.oregonstate.education › computationalbiology › chapter › application-programming-interfaces-modules-packages-syntactic-sugar
Application Programming Interfaces, Modules, Packages, Syntactic Sugar – A Primer for Computational Biology
June 21, 2019 - To use a module, we just need to run import modulename. As it turns out, modules are simply files of Python code ending in .py! Thus, when we use import modulename, the interpreter searches for a modulename.py containing the various function and class definitions.
🌐
GitHub
github.com › ssanderson › python-interface
GitHub - ssanderson/python-interface: Minimal Pythonic Interface Definitions
October 15, 2021 - interface is a library for declaring interfaces and for statically asserting that classes implement those interfaces. It aims to provide stricter semantics and better error messages than Python's built-in abc module.
Starred by 112 users
Forked by 17 users
Languages   Python 100.0% | Python 100.0%
🌐
Javatpoint
javatpoint.com › interface-in-python
Interface in Python - Javatpoint
Create a Modern login UI using the CustomTkinter Module in Python · Deepchecks Testing Machine Learning Models |Python · Develop Data Visualization Interfaces in Python with Dash · Difference between 'del' and 'pop' in python · Get value from Dictionary by key with get() in Python ·
🌐
Reddit
reddit.com › r/python › interfaces in python
r/Python on Reddit: Interfaces in Python
April 12, 2023 - Sometimes you may not even own module b. ... Frequently, when I'm using ABC, I need to perform a string-to-class lookup. For this, I created the library AutoRegistry, which adds a dictionary interface to classes (not objects created from classes!) that is automatically populated with it's children.
🌐
Python GUIs
pythonguis.com › faq › which python gui library should you use?
Which Python GUI library should you use in 2026?
December 23, 2025 - Best all-rounder with batteries included. PyQt and PySide are wrappers around the Qt framework. They allow you to easily create modern interfaces that look right at home on any platform, including Windows, macOS, Linux, and even Android.
🌐
Reddit
reddit.com › r/learnpython › organising interfaces in python packages
r/learnpython on Reddit: Organising interfaces in python packages
February 10, 2022 -

Hello everyone,

I am looking for a best practice how to organise interfaces on a packages point of view. Does somebody know a guide or has experience how to do that that.

For example.

package1
    interface_definition.py # right place?
    package1.1
        module_a
        module_a2
    package1.2
        module_b
        module_b2
    package1.3
        module_c
        module_c2
package2
    package2.1
    package2.2
    package2.3

If module_a, module_b and module_c all implementing the same abstract interface class. The concrete objects of the classes implementing the interface are used so: module_a in module_a2, module_b in module_b2 and so on.

Where would you place such an interface definition? (Interface by ABC)

Greetings Florian