xrange not hashable - why not?

Jeff Epler jepler at unpythonic.net
Sun Jan 25 19:11:45 EST 2004


On Sun, Jan 25, 2004 at 07:06:31PM -0500, Hans Nowak wrote:
> So far, everybody who replied seems to agree or assumes that xrange indeed 
> isn't hashable.  However:
[...]

It wasn't in older versions:
$ python
Python 2.2.2 (#1, Feb 24 2003, 19:13:11) 
[GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> hash(xrange(0))
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: unhashable type

Jeff




More information about the Python-list mailing list