Protocols for Python?

R

redefined.horizons

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
 
J

Jay Parlar

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.
 
H

Harold Fellermann

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.
 
G

Gregor Horvath

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,294
Messages
2,571,511
Members
48,200
Latest member
SCPKatheri

Latest Threads

Top