interface

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.

interface supports Python 2.7 and Python 3.4+.

Quick Start

from interface import implements, Interface

class MyInterface(Interface):

    def method1(self, x):
        pass

    def method2(self, x, y):
        pass


class MyClass(implements(MyInterface)):

    def method1(self, x):
        return x * 2

    def method2(self, x, y):
        return x + y

Indices and tables