[PEAK] Moving forward with PyProtocols and generic
functions
Phillip J. Eby
pje at telecommunity.com
Fri Nov 5 10:16:36 EST 2004
At 02:10 PM 11/5/04 +0100, Jean-Philippe Dutreve wrote:
>instead of
>
> @protocols.adapter_function(IFoo, adapts_types=[int])
> def int_as_foo(anInteger):
> # return an IFoo implementation for anInteger
>
>why not use subject/verb like :
>
> @protocols.function_provides(IFoo, adapts_types=[int])
> def int_as_foo(anInteger):
> # return an IFoo implementation for anInteger
>or
> @protocols.function_returns(IFoo, adapts_types=[int])
> def int_as_foo(anInteger):
> # return an IFoo implementation for anInteger
I thought 'function_provides' would be inconsistent with the other
'X_provides' APIs. I'll consider the function_returns a bit more.
>and for class, why not use the same syntax as other things :
>
> @protocols.instances_provide(IFoo, adapts_protocols=[IBar])
> class Foo:
I don't think class decorators made it into Python 2.4.
More information about the PEAK
mailing list