What is proper way to require a method to be overridden?

Bruno Desthuilliers bdesth.quelquechose at free.quelquepart.fr
Fri Jan 5 10:17:19 EST 2007


Carl Banks a écrit :
> jeremito wrote:
> 
>>I am writing a class that is intended to be subclassed.  What is the
>>proper way to indicate that a sub class must override a method?
> 
> 
> You can't (easily).
> 
> If your subclass doesn't override a method, then you'll get a big fat
> AttributeError when someone tries to call it.

"override" implies that the method is already defined in one of the 
parent classes. So there's no reason for an AttributeError here...

(snip)



More information about the Python-list mailing list