This is a very concise list comprehension form, which is equivalent to the following:
res = []
for value in db.cursor.fetchall():
pairs = []
for index, column in enumerate(value):
pairs.append((columns[index][0], column))
d = dict(pairs)
res.append(d)
The res
list is equivalent to what you wrote above.
1
solved Could you please explain this piece of code?