How to eliminate python3 failure warning for equality operator?

Although the name can be interpreted as three questions, the actual problem is easy to describe. On Linux, I have python 2.7.3 installed and you want to be warned about python 3 incompatibility. So my code snippet ( tester.py) looks like this:

#!/usr/bin/python -3

class MyClass(object):    
    def __eq__(self, other):
        return False

When I execute this piece of code (I think that it should only show the problem, and not the actual piece of code that I use in my project) as

./tester.py

I get the following failure warning:

./tester.py:3: DeprecationWarning: Overriding __eq__ blocks inheritance of __hash__ in 3.x
  class MyClass(object):

My question is: how do I change this piece of code to get rid of the warning, i.e. make it compatible with version 3? I want to implement the equality operator correctly, and not just suppress a warning or something like that.

+5
2

documentation Python 3.4:

__eq__(), __hash__(); __eq__(), __hash__(), . __eq__(), __hash__(), , - ( , -).

, __hash()__.

, __eq()__ __hash()__.

x.__hash__() , x == y x is y hash(x) == hash(y).

__eq()__, __hash()__ None. , .

, __hash()__, , , __hash__ = None, .

+5

Alex: python -3 ; , MyClass , , -, , , , , . MyClass , . , ; , , , , .

- , , , - __hash__ = None (as ), . None , .

    class MyClass (object):
        def __eq__(self, other): return self is other
        __hash__ = None
0

All Articles