how to solve TypeError: list objects are unhashable?

Jorge Vargas jorge.vargas at gmail.com
Fri Jul 28 19:55:28 EDT 2006


Hello list

I'm not a newbie on python but I'm not an expert either and just found out
that code like this gives the above exception.

        self.db={}
        self.db["foo"]=[1,2]
        self.db["bar"]=[2,3]

I now undestand why this is giving me a problem and I think i'm using the
wrong approach

first of all I'm trying to test some code which will have diferent backends
so I'm doing a quick in memory structure that will let me know that the
algoritms are ok.

my data has the following constrains.

I have keywords (foo,bar,etc) and then values (1,2,3,etc.) now each keyword
is unique and each value may or maynot be unique, although it should be
unique but we won't enforce that.

now one keywords may return 0 to n values which are all the values matching
that certain keyword. something similar to a tagging system. We will never
access the data based on values and each Source object has a method with the
signature get(keyword) where keyword is a string. ohh and the values are all
strings too.

does anyone has a good idea on how to implement this (for the test).

thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20060728/4859d2e4/attachment.html>


More information about the Python-list mailing list