> the canonical __ne__ delegation to __eq__ for any class should be implemented as something like
I disagree that your code snippet is the canonical way to write __ne__. I'd write it like this:
def __ne__(self, other):
return not (self == other)
Or just not write it at all. Python will automatically call __eq__ going back to Python 2.4 (and possibly older).
Delegating to __eq__ directly is the wrong way to do it.
> NotImplemented is a sentinel value that should never be evaluated in a boolean context
I don't see why not. I can't think of any use-cases where I would want to *specifically* use NotImplemented in a boolean context, but I see no good reason why I would want it to fail if one happened to do so. |