What is NotImplemented ?

Magnus Lie Hetland mlh at vier.idi.ntnu.no
Sat Apr 27 17:57:06 EDT 2002


In article <lkn0vq34fi.fsf at pc150.maths.bris.ac.uk>, Michael Hudson wrote:
>Alexandre Fayolle <alf at logilab.fr> writes:
>
>> A quick question, here. What is the built in NotImplemented object? 
>> And what can you do with it? I thought I could raise it as an 
>> exception, but this is not the case (I use NotImplementedError instead).
>
>I think you can return it from implementations of, say, __add__ to
>mean roughly "I don't know what to do here".
[snip]

But how is this different from raising NotImplementedError? (If that
doesn't work in this case, why doesn't it?)

>Returning NotImplemented from the __add__ makes Python go off and call
>the __radd__ method.
>
>HTH,
>M.

--
Magnus Lie Hetland                                  The Anygui Project
http://hetland.org                                  http://anygui.org



More information about the Python-list mailing list