BUG? function objects as dictionary keys?

Matt Conway (mjc4y@henson.cs.virginia.edu)
Sat, 30 Jul 1994 16:59:16 GMT

Is this a bug?

I want to make a dictionary whose keys are functions:

def somefunction():
print "this is a dummy function"

my_dict = {somefunction : "a function"}

print my_dict

This code fails with the message:

Traceback (innermost last):
File "junk.py", line 7
my_dict = {somefunction : "a function"}
TypeError: unhashable type

Very odd. The source code for funcobject.c clearly shows a hash
function defined. Is there something I'm missing here?

Thanks!
Matt

-- 
----------------------------------------------------------------------------
Matthew Conway              University of Virginia      
Dept. of Computer Science   Charlottesville, VA 22901   
		  conway@Virginia.EDU 
----------------------------------------------------------------------------