Protocols for Python?

Jay Parlar jparlar at cogeco.ca
Thu Apr 27 15:55:50 EDT 2006


On Apr 27, 2006, at 3:26 PM, redefined.horizons at gmail.com wrote:

> I think I have reached an important moment in my growth as a Python
> Developer. I realize now why interfaces aren't really necessary in
> Python. :]
>
> Still, I'm designing an application that I want to be extendable by
> third-party developers. I'd like to have some sort of documentation
> about what behavior is required by the components that can be added to
> extend the application. I'd thought I might try documenting these
> behaviors as "protocols" instead of creating abstract classes with no
> method implementations.
>
> I stumbled across PyProtocols, but I don't think it is what I am
> looking for. I don't want to "implement" a form of interfaces in the
> python language, just document the required behavior for certain
> objects in my application for other developers.
>
> Is there a standard way to document protocols in Python? Of should I
> come up with something tailored to my needs.
>


PyProtocols, for the most part, can be replaced with RuleDispatch (also 
part of PEAK). On the surface they may look different, but when you get 
down to it, just about anything you can do with PyProtocols you can do 
with RuleDispatch, and there's a lot of stuff you can do with 
RuleDispatch that you can't with PyProtocols.

And, RuleDispatch makes it MUCH easier to have your application 
configurable by third parties.

I started a major project about a year ago with PyProtocols. About half 
way through, RuleDispatch came out, and now all new additions to the 
project use RuleDispatch instead.

Jay P.




More information about the Python-list mailing list