module for working with the result set

Diez B. Roggisch deetsNOSPAM at web.de
Tue May 18 10:57:50 EDT 2004


> myfields=mycur.description
> #since I already had the data I used it.
> d = dict(zip(myfields,mydata[0]))
> Traceback (most recent call last):
>    File "<input>", line 1, in ?
> TypeError: list objects are unhashable

ah, I forgot that the description contains more than the name. But I see you
figured that out yourself.

> 
> then I'd expect your code to work but I get a list of tuples
> [('csono', '5992      '), ('crevision', 'A') ......]

> What I expected to see was
> {'csono': '5992      '...}

You most probably forgot the dict around the zip, as this works:

>>> dict([('csono', '5992      '), ('crevision', 'A')]) 
{'csono': '5992      ', 'crevision': 'A'}


The builtin dict takes a list of tuples and makes them a dictinairy with
keys from the first element of the tuple and values from the second. 

-- 
Regards,

Diez B. Roggisch



More information about the Python-list mailing list