mechanics to specify an interface

U

Uwe Mayer

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

F. GEIGER

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
 

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
473,768
Messages
2,569,575
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top