[EMAIL PROTECTED] (phil hunt) writes: > Suppose I'm writing an abstract superclass which will have some > concrete subclasses. I want to signal in my code that the subclasses > will implement certan methods. Is this a Pythonic way of doing what > I have in mind: > > class Foo: # abstract superclass > def bar(self): > raise Exception, "Implemented by subclass" > def baz(self): > raise Exception, "Implemented by subclass" > > class Concrete(Foo): > def bar(self): > #...actual implemtation... > def baz(self): > #...actual implemtation...
Well, I guess you know this, but if Foo contains no implementation at all, why inherit from it? It would (possibly) be more Pythonic to define an interface instead, or just use duck typing. Cheers, mwh -- nonono, while we're making wild conjectures about the behavior of completely irrelevant tasks, we must not also make serious mistakes, or the data might suddenly become statistically valid. -- Erik Naggum, comp.lang.lisp -- http://mail.python.org/mailman/listinfo/python-list