On Sun, Jul 26, 2020 at 07:47:39PM +0200, Marco Sulla wrote:
> On Sun, 26 Jul 2020 at 19:33, Henry Lin <hlin...@gmail.com> wrote:
> 
> >
> >    - Any class implementing the `__eq__` operator is no longer hashable
> >
> >
> You can use:
> 
> def __hash__(self):
>     return id(self)

Don't do that. It's a horrible hash function.

The `object` superclass already knows how to do a good, reliable hash 
function. Use it.

    def __hash__(self):
        return super().__hash__()


-- 
Steven
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/7N3GMYKC46MRA4DUNS2C5R2CA4CJGMOG/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to