mechanics to specify an interface
F. GEIGER
fgeiger at datec.at
Sat Mar 6 10:01:16 EST 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" <merkosh at hadiko.de> schrieb im Newsbeitrag
news:c2c8kk$oat$1 at news.rz.uni-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
>
More information about the Python-list
mailing list