470,614 Members | 1,396 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,614 developers. It's quick & easy.

Protocols for Python?

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.

Thanks,

Scott Huey

Apr 27 '06 #1
3 1232

On Apr 27, 2006, at 3:26 PM, re****************@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.

Apr 27 '06 #2
re****************@gmail.com wrote:
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.


Use doc strings :-) They are easy to learn, easy to understand (once
you
learned how to write meaningful ones, that is), integrated into the
core
language and supported by IDEs and editors.
Combine a good documentation with proper exception handling and
extending your application will be easy. Bateries inluded, you know.

Apr 27 '06 #3
re****************@gmail.com schrieb:

Is there a standard way to document protocols in Python? Of should I
come up with something tailored to my needs.


Write unittests or doctest strings.

--
Servus, Gregor
http://www.gregor-horvath.com
Apr 28 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Erik Max Francis | last post: by
3 posts views Thread by Efrat Regev | last post: by
2 posts views Thread by Mark Olbert | last post: by
reply views Thread by John | last post: by
1 post views Thread by Mae Lim | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.