Pythonic Abstract Base Class / Interface
Erik Max Francis
max at alcyone.com
Tue Oct 28 17:01:38 EST 2003
Tom Evans wrote:
> If I have a specific interface which I know is going to be implemented
> by a number of classes, but there is no implementation commonality
> between them, what is the preferred form for this in Python?
...
> Is there a clear pythonic way, or does it depend a bit more on the
> design of the specific program?
I usually do something like
class AbstractBase:
def __init__(self):
if self.__class__ is AbstractBase:
raise NotImplementedError
def aMethod(self):
raise NotImplementedError
def anotherMethod(self):
raise NotImplementedError
--
Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
__ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/ \ We grow in time to trust the future for our answers.
\__/ Ruth Benedict
More information about the Python-list
mailing list