Class: Interface | Twisted-0.17.4/twisted/python/components.py |
---|---|
Base class for interfaces.Interfaces define and document an interface for a class. An interface class's name must begin with I, and all its methods must raise NotImplementedError, to show they are abstract. A class that implements an interface should list the interfaces it implements in a class-level list, __implements__. For example: | class IAdder(Interface): | "Objects implementing this interface can add objects." | | def add(self, a, b): | "Add two objects together and return the result." | raise NotImplementedError | | class Adder: | | __implements__ = <a href="#IAdder">[IAdder]</a> | | def add(self, a, b): | return a + b |