How about "pure virtual methods"?

Doug Holton insert at spam.here
Mon Dec 20 19:09:12 EST 2004


Doug Holton wrote:
>> Noam Raphael wrote:
>> even in the best solution that I know of,
>>
>>> there's now way to check if a subclass has implemented all the 
>>> required methods without running it and testing if it works. 
> 
> 
> I think there are some solutions like PyProtocols, see section 2.2 on 
> this page: http://www.python.org/cgi-bin/moinmoin/MetaClasses

Let me rephrase the rest of my answer.

This is something we could use in Python.  You should add a feature 
request to have this in Python 3.0, a.k.a. Python 3000:
http://www.python.org/cgi-bin/moinmoin/Python3.0

You might have simple code such as:

inteface ICallable:
     def Call(args)

However, Python 3.0 is likely years away.  If you want to know how to 
run code like this and have real interfaces, abstract classes and 
virtual methods today, consult Fredrik Lundh.



More information about the Python-list mailing list