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

Thomas Ploch Thomas.Ploch at gmx.net
Thu Jan 4 23:28:41 EST 2007


Grant Edwards schrieb:
> On 2007-01-05, Thomas Ploch <Thomas.Ploch at gmx.net> 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?
>>> If any subclass *must* override a method, raise
>>> NotImplementedError in the base class (apart from documenting
>>> how your class is supposed to be used).
>> I learn so much from this list. I didn't even know this error existed.
> 
> And remember: even if it didn't, you could have created your
> own:

Erm, it wasn't me who asked. I just wanted to say that I didn't know
that there is a NotImplementedError. Havn't seen it before.

:-)

Thomas



More information about the Python-list mailing list