Hello, I'm trying to find the fastest way to convert an sql result into a dict or list. What i mean, for example: my sql result: contact_id, field_id, field_name, value sql_result=[[1, 1, 'address', 'something street'], [1, 2, 'telnumber', '1111111111'], [1, 3, 'email', '[EMAIL PROTECTED]'], [2, 1, 'address','something stree'], [2, 3, 'email','[EMAIL PROTECTED]']] the dict can be: dict={1:['something street', '1111111111' , '[EMAIL PROTECTED]'], 2:['something street', '', '[EMAIL PROTECTED]' ]} or a list can be: list=[[1,'something street', '1111111111' , '[EMAIL PROTECTED]'], [2,'something street', '', '[EMAIL PROTECTED]' ]]
I tried to make a dict, but i think it is slower then make a list, and i tried the "one lined for" to make a list, it's look like little bit faster than make a dict. def empty_list_make(sql_result): return [ [line[0],"", "", ""] for line in sql_result] than fill in the list with another for loop. I hope there is an easyest way to do something like this ?? any idea ? -- http://mail.python.org/mailman/listinfo/python-list