__eq__ and __ne__
jeremy at alum.mit.edu
Tue Jul 8 18:21:29 CEST 2003
On Tue, 2003-07-08 at 12:08, Shane Hathaway wrote:
> Tim Peters wrote:
> > Since the richcmp operators aren't constrained to return scalars, an attempt
> > to define one in terms of the others seemed futile. Instead they're 6
> > independent methods.
> Ok. Thanks for finding the docs. I guess I'll stick to my boilerplate
> code. I think some guidance should be added to the Python docs, though,
> explaining that whenever you define __eq__, you very likely ought to
> define __ne__ also.
I believe C++ has the same behavior when you overload logical
operators. So at least people familiar with the same behavior in other
languages won't be surprised.
More information about the Python-list