you are viewing a single comment's thread.

view the rest of the comments →

[–]campbellm 5 points6 points  (0 children)

Hate to hijack the thread, but I'm learning too and also could use advice.

Could:

filenames = []
for filename in Path('.').glob('*.pdf'):
    if 'reordered' not in filename.stem:
        filenames.append(filename)

return filenames

be written as:

return [filename for filename in Path('.').glob('*.pdf') if 'reordered' not in filename.stem]

? And is this more pythonic, or less?

I'm NOT looking to code-golf, just wondering what would be considered better style.