[Zope-dev] Defining Interfaces

Steve Alexander steve@cat-box.net
Mon, 28 Jan 2002 23:18:56 +0000


Adrian Hungate wrote:
> This is based on the new Python 2.2 stuff, isn't it? I would guess the
> answer would be "You exclude the 'self' first arg in a class method".

Not really. You exclude the "self" first argument of a static method. 
The first argument of a class method is where the class is passed.

The reason that "self" is now excluded when defining interfaces comes 
from considering who reads interface definitions.

By their nature, interfaces are meant to be read from the "outside"; 
from beyond the facade. The "self" attribute of methods is an 
implementation detail, and is not a concern of those who make calls on 
an interface.

With Python2.2, you can demonstrate this by defining a class that has 
static methods only, but which still satisfies some interface 
definition. The "self" argument need not occur at all.

--
Steve Alexander