can a class instance ever be hashable?

lynx a at b.c
Thu Sep 21 22:49:58 EDT 2000


Alex <cut_me_out at hotmail.com>, in
<etdog1hnt13.fsf at x15-cruise-basselope.mit.edu>:

> Read about these methods in the Language Reference documentation.  Any
> class that defines them can be hashable.  In fact you only need to
> define __hash__, but that will lead to confusing results when you have
> different instances that you want to regard as equal for some reason.

thanks. i actually did read about these in my copy of the _essential
reference_ a couple days ago, but it mainly just confused me. i'm
still struggling with python's idea of mutability and how to tell
whether a thing is or isn't, and especially with how to solve my
particular problem so the classes in question are/aren't mutable.

(and not having even remotely finished my design yet isn't helping
my confusion about what to hash. oh well... btw, thanks *greatly*
for the xor suggestion re. combining hash() values; i'd been blind
to anything but addition, and worrying about integer overflow.)



More information about the Python-list mailing list