[Twisted-Python] Questions regarding serviceCollection and Interfaces.

James Y Knight foom at fuhm.net
Wed Jul 6 12:29:03 EDT 2005

On Jul 6, 2005, at 10:18 AM, kgi wrote:
> I do have one question arising from the Zope documentation, though.  
> In the
> link above, it says (abridged):
> """
> class IFoo(zope.interface.Interface):
>     def bar(q, r=None):
>         """bar blah blah"""
> [...]
>   Note that `bar` doesn't take a `self` argument.  Interfaces document
>   how an object is *used*.  When calling instance methods, you don't
>   pass a `self` argument, so a `self` argument isn't included in the
>   interface signature.
> """
> Yet all the examples I've seen in the Twisted documentation have  
> interface
> methods that contain "self" parameters

Twisted hasn't always used Zope Interfaces -- we used to have our  
own. In our implementation, we *did* use self as the first argument.  
Thus, the general rule is, if you inherit from  
twisted.python.components.Interface (our backwards compatibility  
wrapper), you should follow our rule and include self as the first  
argument. However, if you inherit directly from  
zope.interface.Interface, you should follow zope's rule and not  
include self.

That said, the signature isn't really used for anything at the  
moment. I've played around with an interface enforcement wrapper that  
does use the signature, but that's just playing around at the moment.


More information about the Twisted-Python mailing list