[PEAK] Feedback wanted: PyProtocols 1.0 convenience API

Phillip J. Eby pje at telecommunity.com
Mon Oct 18 12:09:17 EDT 2004


At 12:18 PM 10/18/04 +0200, Ulrich Eck wrote:
> > from protocols import performs, provides, module_provides
> > from protocols import instances_provide, class_provides
> >
> > @performs(IFoo)
> > def afunc(...):
> >      """Perform the behavior defined by IFoo.__call__"""
>
>could you provide an example of how this would be done right now?
>i don't understand the meaning of your declaration above.

def afunc(...)
     ...

protocols.adviseObject(aFunc,[IFoo])




> > class Bar:
> >      instances_provide(IBar)
>
>why would you switch from capitalized names (e.g instancesProvide) to
>underscores ?

Because that's the preferred style for the Python standard library.  As 
long as I'm introducing new functions anyway, I might as well conform to 
stdlib.  While at present it seems unlikely PyProtocols will ever become 
part of the stdlib, I might as well remove any obstacles I can.


>how would the factoryMethod be specified for classes that are adatpers ?

as a factory_method keyword to 'instances_provide()'.




More information about the PEAK mailing list