[Zope3-dev] Twisted framework refactored
Steve Alexander
steve@cat-box.net
Sun, 21 Apr 2002 12:47:38 +0100
Phillip J. Eby wrote:
>
> The difference, for anyone who cares, is that Twisted specifically
> considers '__implements__' to be a *class* attribute, not an instance
> attribute.
I'd say __implements__ should be an object attribute. So, a module can
implement something. An object() can implement something, by setting
appropriate attributes on it, and setting its __implements__ attribute.
In Python 2.2, a function can implement something:
>>> from Interface import Interface
>>> l = lambda: 1
>>> l.__dict__['__implements__'] = Interface
>>> l.__implements__
<Interface Interface._Interface.Interface at 81a94a4>
>>>
Specifically considering __implements__ to be a class attribute is
wrong, as it adds an unnecessary dependency between the type of an
object, and its contractual obligations.
--
Steve Alexander