Is this Pythonic?
phil hunt
zen19725 at zen.co.uk
Tue Aug 2 04:51:19 EDT 2005
On Tue, 02 Aug 2005 08:31:27 GMT, Michael Hudson <mwh at python.net> wrote:
>zen19725 at zen.co.uk (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?
(in fact the class I'm using/creating does contain some
implementation)
>It would (possibly) be more Pythonic to
>define an interface instead,
Does Python have the concept of an interface? When was that added?
--
Email: zen19725 at zen dot co dot uk
More information about the Python-list
mailing list