Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > mechanics to specify an interface

Reply
Thread Tools

mechanics to specify an interface

 
 
Uwe Mayer
Guest
Posts: n/a
 
      03-06-2004
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

 
Reply With Quote
 
 
 
 
F. GEIGER
Guest
Posts: n/a
 
      03-06-2004
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$...
> 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
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mechanics of calculating structure-member offsets cman C Programming 9 03-03-2007 08:46 PM
Photo Mechanics Pro Larry R Harrison Jr Digital Photography 3 09-09-2005 09:54 PM
ANN: BOTEC 0.3 -- An astrophysical and orbital mechanics calculator Erik Max Francis Python 0 01-16-2005 12:27 AM
ANN: BOTEC 0.2 -- An astrophysical and orbital mechanics calculator Erik Max Francis Python 0 09-19-2004 12:10 AM
DDE Link Mechanics James Computer Information 2 12-08-2003 04:21 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57