Home | Trees | Index | Help |
|
---|
Package twisted :: Package python :: Module components :: Class Interface |
|
object
--+
|
Interface
IResource
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 should have no implementation code.
Objects that implement an interface should have an attribute __implements__, that should be either an Interface subclass or a tuple, or tuple of tuples, of such Interface classes.
A class whose instances implement an interface should list the interfaces its instances implement in a class-level __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.' | | class Adder: | | __implements__ = IAdder | | def add(self, a, b): | return a + bYou can call an Interface with a single argument; If the passed object can be adapted to the Interface in some way, the adapter will be returned.
Method Summary | |
---|---|
adaptWith(self,
using,
to,
registry)
(Class method) | |
Inherited from object | |
x.__init__(...) initializes x; see x.__class__.__doc__ for signature | |
x.__delattr__('name') <==> del x.name | |
x.__getattribute__('name') <==> x.name | |
x.__hash__() <==> hash(x) | |
helper for pickle | |
helper for pickle | |
x.__repr__() <==> repr(x) | |
x.__setattr__('name', value) <==> x.name = value | |
x.__str__() <==> str(x) | |
Inherited from type | |
T.__new__(S, ...) -> a new object with type S, a subtype of T |
Home | Trees | Index | Help |
|
---|
Generated by Epydoc 2.0 on Thu Dec 25 10:59:57 2003 | http://epydoc.sf.net |