[Python-3000] ABC's, Roles, etc
benji at benjiyork.com
Thu May 10 15:06:24 CEST 2007
Phillip J. Eby wrote:
> At 06:11 PM 5/9/2007 -0400, Benji York wrote:
>> By way of clarification: Even in the large Zope 3 projects I work on
>> (which obviously use zope.interface), we virtually never use
>> interfaces for LBYL (just as Zope 3 itself rarely does).
> Yet, this is precisely what Jeff is claiming zope.interface is
> useful/desirable *for*,
I'll let him speak for himself.
> and Jim Fulton has also been quite clear that
> LBYL is its very raison d'etre.
I would let Jim speak for himself too, but I prefer to put words in his
mouth. ;) While zope.interface has anemic facilities for "verifying"
interfaces, few people use them, and even then rarely outside of very
simple "does this object look right" when testing. It may have been
believed verification would be a great thing, but it's all but
deprecated at this point.
> And thus, for all of the use cases you just described, the minimal
> PEP 3124 Interface implementation should do just fine, yes?
Could be, especially if it allows for adaptation. I don't have the time
to pour over the PEP right now. My main intent in piping up was
dispelling the LBYL dispersions about zope.interface. ;)
If the PEP cooperates as well with zope.interface as you suggest, all
will be good in the world. Personally I'd prefer sufficient hooks be
added to the language and these types of things (interfaces, adaptation,
generic functions, etc.) be left to third parties (like yourself)
instead of being canonicalized unnecessarily.
> ABCs would work for those use cases too, if you didn't need
> adaptation. Or am I missing something?
The main advantage I see to zope.interface is adaptation. Other than
that, the fact that the inheritance and interface hierarchies aren't mixed.
I would turn the argument around and assert that interfaces can be used
for the rare LBYL uses that ABCs appear to be aimed at, as well as more
More information about the Python-3000