[Zope3-dev] Interface surprise
Phillip J. Eby
pje@telecommunity.com
Mon, 31 Mar 2003 11:12:51 -0500
At 10:01 AM 3/31/03 -0500, Shane Hathaway wrote:
>I've been using the following idiom in Zope 2 to discover whether an
>object is an interface definition:
>
>
>from Interface import Interface
>
>def isInterface(obj):
> return Interface.isImplementedBy(obj)
>
>
>This idiom has a little surprise, though: any object that implements any
>interface also implements Interface. Since the above function yields
>numerous false positives, I don't know the right way to detect whether an
>object is an Interface.
I think you want IInterface.isImplementedBy(). However, it's probably
reasonable for the Zope 3 interface API to export an 'isInterface'
function, too.