Documentation of __hash__
Ethan Furman
ethan at stoneleaf.us
Tue Feb 11 12:31:14 EST 2020
On 02/11/2020 02:23 AM, klauck2 at gmail.com wrote:
> On Friday, February 7, 2020 at 4:30:23 PM UTC+1, Random832 wrote:
>> The purpose of this rule is to save you from having to override the default __hash__ with something that will only raise an exception when you do not intend your class to be hashable.
>
> If I do not intend my class to be hashable, I will set __hash__ to None (according to the documentation).
If you define your own __eq__ method, __hash__ is automatically set to None.
--
~Ethan~
More information about the Python-list
mailing list