This is an incorrect usage of NotImplemented. NotImplemented is a built-in constant used for binary special methods to indicate that there is not a implemented manner to handle a specific type. (see docs)
Essentially if you were to try a.__add__(b), hitting a NonImplemented would allow for a try of b.__add__(a).
Attempting to raise NotImplemented doesn't make sense as it is not an exception. NotImplementedError can be used instead
Example from repl:
>>> raise NotImplemented
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: exceptions must derive from BaseException
>>> raise NotImplementedError
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NotImplementedError
This is an incorrect usage of
NotImplemented
.NotImplemented
is a built-in constant used for binary special methods to indicate that there is not a implemented manner to handle a specific type. (see docs)Essentially if you were to try
a.__add__(b)
, hitting aNonImplemented
would allow for a try ofb.__add__(a)
.Attempting to raise
NotImplemented
doesn't make sense as it is not an exception.NotImplementedError
can be used insteadExample from repl: