Return the interfaces implemented for a class' instances
The value returned is an IDeclaration.
>>> from zope.interface import Interface >>> class I1(Interface): pass ... >>> class I2(I1): pass ... >>> class I3(Interface): pass ... >>> class I4(I3): pass ... >>> class C1(object): ... implements(I2) >>> class C2(C1): ... implements(I3) >>> [i.getName() for i in implementedBy(C2)] ['I3', 'I2']
Really, any object should be able to receive a successful answer, even an instance:
>>> class Callable(object): ... def __call__(self): ... return self>>> implementedBy(Callable()) <implementedBy zope.interface.declarations.?>
Note that the name of the spec ends with a '?', because the Callable instance does not have a __name__ attribute.