Skip to content

Instantly share code, notes, and snippets.

@vitalibertas
Last active August 30, 2018 17:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vitalibertas/b16ed8a13d7d2d0516ef2d1b57b60402 to your computer and use it in GitHub Desktop.
Save vitalibertas/b16ed8a13d7d2d0516ef2d1b57b60402 to your computer and use it in GitHub Desktop.
Readability: Python List Comprehension vs. Not
# List Comprehension:
process_dict = dict([(attributes.filename, attributes.st_size) for attributes in file_list if attributes.filename.startswith('solcon')])
# Whitespace Generous:
for attributes in file_list:
if attributes.filename.startswith('solcon'):
process_dict[attributes.filename] = attributes.st_size
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment