pure virtual functions in python
Delaney, Timothy
tdelaney at avaya.com
Sun Jan 12 20:38:45 EST 2003
> From: polux [mailto:polux2001 at wanadoo.fr]
>
> how to emulate them ?
> I mean, how to force a user to redifine some functions in a derivated
> class ?
Most responses have used `NotImplementedError`. This is fine, and useful if
you want the abstract class to document what methods it defines.
The other approach is to document what attributes/methods other functions
require their parameters to have. This achieves the same effect (but throws
an `AttributeError` rather than a `NotImplementedError`), but is in many
ways more versatile.
I have never used `NotImplementedError` in my python code. Why bother?
Tim Delaney
More information about the Python-list
mailing list