[Zope3-dev] Re: zope.interface.Interface.(isImplementedBy vs implementedBy)

Martin Aspeli optilude at gmx.net
Tue Sep 19 18:59:04 EDT 2006


Chris Withers wrote:
> Hi All,
> 
> What's the difference between these two?
> 
> implementedBy is what I meant to use, by I braino'ed isImplementedBy 
> instead.

     def providedBy(object):
         """Test whether the interface is implemented by the object

         Return true of the object asserts that it implements the
         interface, including asserting that it implements an extended
         interface.
         """

     def implementedBy(class_):
         """Test whether the interface is implemented by instances of 
the class

         Return true of the class asserts that its instances implement the
         interface, including asserting that they implement an extended
         interface.
         """
...

     def isImplementedBy(self, ob):
         warnings.warn(
             "isImplementedBy has been renamed to providedBy",
             DeprecationWarning, stacklevel=2,
             )
         return self.providedBy(ob)

That's 2.10, grep lib/python/zope/interface on your own instance in case 
it's changed. However, IFoo.providedBy(obj) and 
IFoo.implementedBy(obj.__class__) should be the same.

> Rather than getting an AttributeError, I just got unexpected behaviour :-(

You know as well as anyone that this is a pointless message without any 
more detail.

Martin



More information about the Zope3-dev mailing list