Dictionary of tuples from query question

David Pratt fairwinds at eastlink.ca
Mon Nov 14 14:03:55 EST 2005


Thanks Fredrik for your help. Really short and efficient - very nice!

Regards,
David

On Monday, November 14, 2005, at 12:12 PM, Fredrik Lundh wrote:

> I meant to write
>
>     d = {}
>     for index, record in enumerate(cursor.fetchall()):
>         d[index+1] = tuple(record)
>
> which can be shorted to
>
>     d = dict((k+1, tuple(v)) for k, v in enumerate(x))
>
> in recent versions of Python.



More information about the Python-list mailing list