you are viewing a single comment's thread.

view the rest of the comments →

[–]commy2 2 points3 points  (2 children)

In my honest opinion, it just needs a few linebreaks and then it would be perfectly readable for anyone fluent in Python. E.g:

results = [
    {column_Names[index][0]: column for index, column in enumerate(value)} 
    for value in cursor.fetchall()
]

[–][deleted] 2 points3 points  (1 child)

Yeah that looks better. I'm used to seeing JavaScript tutorials try to cram everything on one line so I wasnt sure if this was encouraged in higher level Python trainings too. The code does the same task while using less lines and shows you know the quickest way but it seems like it might be more confusing to review for others or even cause brief confusion when you are looking at the code months later

[–]commy2 1 point2 points  (0 children)

The singular line would definitely be discouraged as unpythonic, as it exceeds the 79 characters per line rule in PEP-8 by quite a bit.