4 ms·
Twisted, the Python networking framework, makes extensive use of interfaces in its API. The "Interfaces and Adapters" chapter in the documentation goes in to so
by thristian 16y ago
Twisted, the Python networking framework, makes extensive use of interfaces in its API. The "Interfaces and Adapters" chapter in the documentation goes in to some detail about why you would want such a thing:
http://twistedmatrix.com/documents/current/core/howto/components.html http://twistedmatrix.com/documents/current/core/howto/compon...
If you're in a hurry, the main motivations appear to be:
- declaring that a class supports particular functionality without risking the complications of multiple inheritance
- the ability to register adapters from one interface to another means no more calls to isinstance() (or at least, they're abstracted away to a library function)
- Easy to make your test suite check that you haven't forgotten to implement any methods of any of the interfaces your class claims to support.