Why does __ne__ exist?
Chris Angelico <rosuav at gmail.com> writes:
> On Mon, Jan 8, 2018 at 10:55 AM, Ben Finney <ben+python at benfinney.id.au> wrote:
> > We've established that it is useful to allow data types to define
> > their own meaning of ?equal? and ?not equal?, like many other
> > operations. Is that not good enough reason to allow it still?
> The fact that container types can define "contains" but can't define
> "doesn't contain", and that (as of Py3) there's proper default
> handling, suggests that it's not as big a priority now.
That is an inconsistency, I agree.
> 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.
> Make sure you mention the potential confusion when subclassing.
For example, that would alsop be a problem for multiple inheritance. Not
?absolutely needed?, and high risk of confusion when subclassing. Do you
think that multiple inheritance would thereby also not be allowed today?
If you consider that a different case, why?
\ ?First they came for the verbs, and I said nothing, for verbing |
`\ weirds language. Then, they arrival for the nouns and I speech |
_o__) nothing, for I no verbs.? ?Peter Ellis |