Displaying 1 result from an estimated 1 matches for "__ne__".
Did you mean:
__new__
2009 Oct 12
0
What is the correct way to define __hash__?
...arisons.
> ?# I recommend doing this for the equality comparisons, at least, when you
> can
> ?# because of the requirement that two items that compare equal must have
> the
> ?# same hash value.
> ?def __eq__(self, other):
> ? ?return self._key() == other._key()
>
> ?def __ne__(self, other):
> ? ?return not (self == other)
>
> ?...
Do I need to define other 4 comparison operators besides __eq__ and __ne__?