Author steven.daprano
Recipients josh.r, steven.daprano, xtreak
Date 2019-01-11.01:44:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1547171041.41.0.673000572335.issue35712@roundup.psfhosted.org>
In-reply-to
Content
> 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.
History
Date User Action Args
2019-01-11 01:44:02steven.dapranosetrecipients: + steven.daprano, josh.r, xtreak
2019-01-11 01:44:01steven.dapranosetmessageid: <1547171041.41.0.673000572335.issue35712@roundup.psfhosted.org>
2019-01-11 01:44:01steven.dapranolinkissue35712 messages
2019-01-11 01:44:01steven.dapranocreate