Why does __ne__ exist?

Ethan Furman ethan at stoneleaf.us
Mon Jan 8 00:21:37 EST 2018


On 01/07/2018 04:57 PM, Chris Angelico wrote:
> On Mon, Jan 8, 2018 at 11:35 AM, Ben Finney wrote:
>> Chris Angelico writes:

>>> Let's put it this way. Suppose that __eq__ existed and __ne__ didn't,
>>> just like with __contains__. Go ahead: sell the notion of __ne__.
>>> Pitch it, show why we absolutely need to allow this.
>>
>> I think “reject unless absolutely needed” is an unreasonably high bar,
>> which would disqualify most Python language features. So I don't know
>> why you expect this to be so especially strongly argued.
>
> True, I exaggerated a bit. But do you think that, had __ne__ not
> existed for years, its addition could be justified?

Considering we just recently added a matrix-multiplication operator, yes.

--
~Ethan~




More information about the Python-list mailing list