Python not implemented exception

This exception is used during development to indicate that in that place you need to implement some functionality. To learn how to fix any kind of exceptions we always refer to https://fixexception.com/. This service allows finding fixes for the most popular python exceptions.

But this time I want to give a detailed explanation on certain exception.

For example method in a subclass.

Let's define a parent class:

class Animal(object):
    def __init__(self, speed):
        self.speed = speed

    def run(self):
        raise NotImplementedError('You need to implement this method in %s.' % self.__class__.__name__)

And some child class which will inherit all methods:

class Rabbit(Animal):
    pass

Now let's try to create a class instance and run a method from the parent class:

rabbit = Rabbit(speed=20)
rabbit.run()

Output:

in run raise NotImplementedError(NotImplementedError: You need to implement this method in Rabbit.)

So it says that you are using a method that actually is not implemented, so most likely you have to implement it in Rabbit class.

Screaming women after seen Not Implemented error

#python #exception
0
Roman Ivashchenko profile picture
Nov 25, 2020
by Roman Ivashchenko
Did it help you?
Yes !
No

Best related