[PEAK] protocols question

Phillip J. Eby pje at telecommunity.com
Tue Feb 21 12:11:15 EST 2006


At 07:02 PM 2/21/2006 +0200, Vladimir Iliev wrote:
>issubclass() will works, but if i use subclasses instead of instances,
>i'm not aware of a way to implement the equivalent functionality of
>advise(protocolIsSubsetOf=[...]). probably it's yagni but who knows ...

You can assign to the target class' __bases__.

Or you can just create your own tag data structure and methods for them 
that do all this.  If you later need the optimization of having an index, 
the dispatch framework is extensible.  For example, peak.binding.components 
creates a custom "criterion" class (HasParentCriterion) that indexes 
component parent hierarchies to make it possible for generic functions to 
evaluate "is X a child of Y?" questions in parallel.




More information about the PEAK mailing list