Protocols for Python?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • redefined.horizons@gmail.com

    #1

    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

  • Jay Parlar

    #2
    Re: Protocols for Python?


    On Apr 27, 2006, at 3:26 PM, redefined.horiz ons@gmail.com wrote:
    [color=blue]
    > 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.
    >[/color]


    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.

    Comment

    • Harold Fellermann

      #3
      Re: Protocols for Python?

      redefined.horiz ons@gmail.com wrote:[color=blue]
      > 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 .[/color]

      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.

      Comment

      • Gregor Horvath

        #4
        Re: Protocols for Python?

        redefined.horiz ons@gmail.com schrieb:[color=blue]
        >
        > Is there a standard way to document protocols in Python? Of should I
        > come up with something tailored to my needs.
        >[/color]

        Write unittests or doctest strings.

        --
        Servus, Gregor
        Firma Gregor Horvath, Ing. - Industrieberatung & Softwareentwicklung, Wien, infor:COM, Tryton, ERP, Web, GNU/Linux

        Comment

        Working...