mechanics to specify an interface

Discussion in 'Python' started by Uwe Mayer, Mar 6, 2004.

  1. Uwe Mayer

    Uwe Mayer Guest

    Hi,

    in my program I want to "specify" that some object implements i.e. the
    dictionary or list interface.
    What is the Python way to do that?

    i.e. in Java I'd include an interface.
    in Python I could write an abstract class and inherit from it (probably
    needs multiple inheritance), or I could just specify that in a comment.

    What'd you suggest?
    Thanks in advance
    Uwe
    Uwe Mayer, Mar 6, 2004
    #1
    1. Advertising

  2. Uwe Mayer

    F. GEIGER Guest

    I usually do that this way:

    class IExpense:
    def id(self):
    raise NotImplementedError

    class TimeExposure(IExpense):
    def __init__(self, ...):
    ...

    def id(self):
    ...

    HTH
    Franz GEIGER

    "Uwe Mayer" <> schrieb im Newsbeitrag
    news:c2c8kk$oat$-karlsruhe.de...
    > Hi,
    >
    > in my program I want to "specify" that some object implements i.e. the
    > dictionary or list interface.
    > What is the Python way to do that?
    >
    > i.e. in Java I'd include an interface.
    > in Python I could write an abstract class and inherit from it (probably
    > needs multiple inheritance), or I could just specify that in a comment.
    >
    > What'd you suggest?
    > Thanks in advance
    > Uwe
    >
    F. GEIGER, Mar 6, 2004
    #2
    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. Erik Max Francis
    Replies:
    0
    Views:
    507
    Erik Max Francis
    Sep 19, 2004
  2. Erik Max Francis
    Replies:
    0
    Views:
    331
    Erik Max Francis
    Jan 16, 2005
  3. cman
    Replies:
    9
    Views:
    371
    CBFalconer
    Mar 3, 2007
  4. Octavio

    fluid mechanics java library ?

    Octavio, May 31, 2008, in forum: Java
    Replies:
    1
    Views:
    568
    Jeff Higgins
    May 31, 2008
  5. Replies:
    0
    Views:
    217
Loading...

Share This Page