python interfaces

Discussion in 'Python' started by hyperboreean, Jan 4, 2008.

  1. hyperboreean

    hyperboreean Guest

    Hi,
    Probably it has been asked before, but I'll still ask.
    Why doesn't python provide interfaces trough its standard library? Or it
    was ever proposed to be included in the language?
    Zope's implementation seems pretty flexible and straightforward.

    Thanks.
    hyperboreean, Jan 4, 2008
    #1
    1. Advertising

  2. On Jan 4, 3:59 pm, hyperboreean <> wrote:
    > Hi,
    > Probably it has been asked before, but I'll still ask.
    > Why doesn't python provide interfaces trough its standard library? Or it
    > was ever proposed to be included in the language?
    > Zope's implementation seems pretty flexible and straightforward.
    >
    > Thanks.


    Python 3.0 will introduce Abstract Base Classes:

    http://www.python.org/dev/peps/pep-3119/
    Michele Simionato, Jan 4, 2008
    #2
    1. Advertising

  3. hyperboreean <> wrote:
    >Why doesn't python provide interfaces trough its standard library?


    Because they're pointless. Java interfaces are a hack around the
    complexities of multiple inheritence. Python does multiple
    inheritence Just Fine (give or take the subtleties of super()) so
    does not need them.

    Interfaces used purely with the idea of type safety provide
    precious little gain for the added clutter and inconvenience.
    Compare them to Java's requirement for explicit declaration of
    exceptions thrown in a method signature, if you will.

    --
    \S -- -- http://www.chaos.org.uk/~sion/
    "Frankly I have no feelings towards penguins one way or the other"
    -- Arthur C. Clarke
    her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump
    Sion Arrowsmith, Jan 4, 2008
    #3
  4. hyperboreean

    Peter Maas Guest

    Sion Arrowsmith wrote:
    > hyperboreean <> wrote:
    >> Why doesn't python provide interfaces trough its standard library?

    >
    > Because they're pointless.


    Wrong. I'm using Eclipse with the Java Development Tools (JDT) who do
    a wonderful job using interfaces to perform lots of checking, warning
    and code generation *nearly in real time while I am editing my code*.
    Because JDT knows interfaces it knows what to do and to suggest. An
    interface is a software specification allowing you to use a software
    package without extensive code studies. This is a good thing.

    > Java interfaces are a hack around the complexities of multiple
    > inheritence.


    A hack is something applied subsequently to solve a software problem while
    avoiding large changes. Java interfaces originate from careful language
    design. You are free to dislike Java interfaces but calling them a hack is
    just plain wrong.

    Once software becomes really big interfaces are very useful to handle
    complexity. Ever wondered why the Zope people introduced interfaces in
    their Python code?

    > Interfaces used purely with the idea of type safety provide
    > precious little gain for the added clutter and inconvenience.


    An interface is a software specification allowing you to use a software
    package without extensive code studies. This is a good thing. Interfaces
    have nothing to do with multiple inheritance. They just tell you how to
    connect, how to plug in.

    --
    Regards/Gruesse,

    Peter Maas, Aachen
    E-mail 'cGV0ZXIubWFhc0B1dGlsb2cuZGU=\n'.decode('base64')
    Peter Maas, Jan 5, 2008
    #4
  5. hyperboreean

    Peter Maas Guest

    Sion Arrowsmith wrote:
    > hyperboreean <> wrote:
    >> Why doesn't python provide interfaces trough its standard library?

    >
    > Because they're pointless.


    Wrong. I'm using Eclipse with the Java Development Tools (JDT) who do
    a wonderful job using interfaces to perform lots of checking, warning
    and code generation *nearly in real time while I am editing my code*.
    Because JDT knows interfaces it knows what to do and to suggest.

    > Java interfaces are a hack around the complexities of multiple
    > inheritence.


    A hack is something applied subsequently to solve a software problem while
    avoiding large changes. Java interfaces originate from careful language
    design. You are free to dislike Java interfaces but calling them a hack is
    just plain wrong.

    Once software becomes really big interfaces are very useful to handle
    complexity. Ever wondered why the Zope people introduced interfaces in
    their Python code?

    > Interfaces used purely with the idea of type safety provide
    > precious little gain for the added clutter and inconvenience.


    An interface is a software specification allowing you to use a software
    package without extensive code studies. This is a good thing. Interfaces
    have nothing to do with multiple inheritance and are not about type safety
    in the first place. They just tell you how to connect, how to plug in.

    --
    Regards/Gruesse,

    Peter Maas, Aachen
    E-mail 'cGV0ZXIubWFhc0B1dGlsb2cuZGU=\n'.decode('base64')
    Peter Maas, Jan 5, 2008
    #5
  6. hyperboreean

    Guest

    On Jan 4, 6:01 pm, Sion Arrowsmith <>
    wrote:
    > hyperboreean <> wrote:
    > >Why doesn't python provide interfaces trough its standard library?

    >
    > Because they're pointless. Java interfaces are a hack around the
    > complexities of multiple inheritence. Python does multiple
    > inheritence Just Fine (give or take the subtleties of super()) so
    > does not need them.
    >

    Hallo,
    Interfaces are a extremly smart Design Principle in static typed
    languages
    like Java and C++.
    C++ support Interfaces in a form of abstract base classes. They aren't
    pointless.
    They force the user of a framework to use it in a defined way. You
    prescribe in
    the base class the usage of a classsystem and allow only in derived
    classes
    to variate the behavior.
    To appreciate Interfaces look at the Template Methode Pattern (http://
    en.wikipedia.org/wiki/Template_method_pattern )
    or especially at the Non Virtual Interface ( http://www.gotw.ca/publications/mill18.htm
    ) Idiom from Herb Sutter.

    To be short C++ support Interfaces and multiple inheritace.

    Greetings Rainer
    , Jan 6, 2008
    #6
  7. wrote:

    > Interfaces are a extremly smart Design Principle in static typed
    > languages like Java and C++.


    that's somewhat questionable in itself, and even more questionable as an
    argument for interfaces in Python.

    I'd recommend anyone who thinks that they cannot program without formal
    interfaces to try using Python as Python for a while, before they try
    using it as something else. you might be surprised over how easy it is
    to build robust stuff without having to add lots of extra constraints to
    your code.

    </F>
    Fredrik Lundh, Jan 6, 2008
    #7
  8. hyperboreean

    Carl Banks Guest

    On Sat, 05 Jan 2008 23:31:02 -0800, r.grimm wrote:
    > They force the user of a framework to use it in a defined way.


    This is the arrogance of the provider thinking that he can anticipate all
    the needs of the user.

    Even when interfaces exist, they should be there to guide the user rather
    than to force the user. A user should be able to refuse to implement the
    interface, if the user knows that full implmentation is not necessary, or
    dangerous. Frankly, a lot of interfaces suck. The user is often a lot
    smarter than the provider, and nearly always knows his needs better. My
    sympathies in these matters are entirely on the user's side--I know
    that's very different from the philosophies of languages like C++ and
    Java.

    There's a time and a place for interfaces. Your average run-of-the-mill
    polymorphism is not it. Usually interfaces are more of a burden than a
    benefit, especially in code that is young and still subject to lots of
    redesign and refactoring.

    And ehen interfaces do make sense, such as in a plugin system or a
    complex framework, the user should be free to ignore the interface at his
    own risk.



    Carl Banks
    Carl Banks, Jan 6, 2008
    #8
  9. Sion Arrowsmith a écrit :
    > hyperboreean <> wrote:
    >
    >>Why doesn't python provide interfaces trough its standard library?

    >
    >
    > Because they're pointless.

    (snip rant about Java's "interfaces")

    Hem... Zope3's "interface" system is not exactly the same thing as
    Java's one.
    Bruno Desthuilliers, Jan 6, 2008
    #9
  10. hyperboreean

    Guest

    On Jan 6, 11:01 am, Fredrik Lundh <> wrote:
    > wrote:
    > > Interfaces are a extremly smart Design Principle in static typed
    > > languages like Java and C++.

    >
    > that's somewhat questionable in itself, and even more questionable as an
    > argument for interfaces in Python.
    >
    > I'd recommend anyone who thinks that they cannot program without formal
    > interfaces to try using Python as Python for a while, before they try
    > using it as something else. you might be surprised over how easy it is
    > to build robust stuff without having to add lots of extra constraints to
    > your code.
    >
    > </F>

    Hallo,
    I argued, that Interface and multiple inheritance are different
    things and
    especially, that Interfaces are very useful in staticially typed
    languages.
    In such languages like Java and C++ you need a formalismen to guide
    the user.
    You may call it extension point, pure virtual function or abstract
    methode.

    Sorry for the misunderstanding, I argued for Interface in heavyweight
    static
    typed languages and nor for lightweight dynamic typed languages like
    python.
    They aren't pointless and a hack.

    Greetings Rainer
    , Jan 7, 2008
    #10
  11. Bruno Desthuilliers <> wrote:
    >Sion Arrowsmith a écrit :
    >(snip rant about Java's "interfaces")
    >
    >Hem... Zope3's "interface" system is not exactly the same thing as
    >Java's one.


    Yeah, I was in need of letting off some steam in general and
    didn't pay enough attention that what I was ranting about was
    on topic. Given that Zope3's "interfaces" are the kind of thing
    under discussion, the correct response is obviously Michele's
    pointing at the ABC PEP.

    --
    \S -- -- http://www.chaos.org.uk/~sion/
    "Frankly I have no feelings towards penguins one way or the other"
    -- Arthur C. Clarke
    her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump
    Sion Arrowsmith, Jan 7, 2008
    #11
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Thomas Weholt

    Interfaces in python

    Thomas Weholt, May 6, 2004, in forum: Python
    Replies:
    3
    Views:
    324
    Michael Hudson
    May 7, 2004
  2. Brian Kazian

    Python Equivalent to Java Interfaces?

    Brian Kazian, Apr 9, 2005, in forum: Python
    Replies:
    4
    Views:
    679
    Michele Simionato
    Apr 9, 2005
  3. Fernando
    Replies:
    1
    Views:
    385
  4. James Harris

    Python music interfaces

    James Harris, Nov 10, 2005, in forum: Python
    Replies:
    2
    Views:
    385
  5. Replies:
    43
    Views:
    894
    bruno at modulix
    Apr 24, 2006
Loading...

Share This Page