Difference of hash and __hash__()
Delaney, Timothy C (Timothy)
tdelaney at avaya.com
Tue Sep 2 23:35:31 CEST 2003
> From: Terry Reedy [mailto:tjreedy at udel.edu]
> "Stefan Fleiter" <stefan.fleiter at web.de> wrote in message
> news:bj2nv5$hna$1 at news.web.de...
> > under Python 2.2.2:
> > >>> s = slice(None,5,None)
> > >>> hash(s)
> > Traceback (most recent call last):
> > File "<stdin>", line 1, in ?
> > TypeError: unhashable type
> > >>> s.__hash__()
> > 136775584
> > Can anybody explain this?
> It looks like a bug. Extended slices were added for use by Numerical
> Python. It may never have tried to hash them or only done so only
> through the C equivavlent of s.__hash__. Extended slicing of
> sequences was, I believe, only added in 2.3.
Looks like a bug to me too. Stefan, please raise a bug report on Sourceforge (or it will get lost). Preferably add a patch and test suite ;)
More information about the Python-list