How about "pure virtual methods"?

Noam Raphael noamr at remove.the.dot.myrea.lbox.com
Fri Dec 31 06:59:45 EST 2004


Thanks for your suggestion, but it has several problems which the added 
class solves:

* This is a very long code just to write "you must implement this 
method". Having a standard way to say that is better.
* You can instantiate the base class, which doesn't make sense.
* You must use testing to check whether a concrete class which you 
derived from the base class really implemented all the abstract methods. 
Testing is a good thing, but it seems to me that when the code specifies 
exactly what should happen, and it doesn't make sense for it not to 
happen, there's no point in having a separate test for it.

About the possibility of implementing only a subset of the interface: 
You are perfectly welcomed to implement any part of the interface as you 
like. Function which use only what you've implemented should work fine 
with your classes. But you can't claim your classes to be instances of 
the base class - as I see it, subclasses, even in Python, guarantee to 
behave like their base classes.

Have a good day,
Noam



More information about the Python-list mailing list