how can I put an Exception as the key of a hash table

yinglcs at gmail.com yinglcs at gmail.com
Sat Apr 28 14:53:51 EDT 2007


I want to keep track of the number of different exception happens in
my python program:

ErrorHash = {}

try:

 # come code ...

 except Exception, e:
            print e
            errcode = e

            if (ErrorHash.has_key(errcode)):
                ErrorFailNo = ErrorHash[errcode]

                ErrorHash[errcode] = ErrorFailNo + 1

            else:
                ErrorHash[errcode] = 1


But when i print out the ErrorHash like this:

print ErrorHash

i get an empty string.  Can you please tell me how can I put an
Exception as the key of a hash table ? Or how can i dump out all the
content of the hashtable.

Thank you.




More information about the Python-list mailing list