Created
January 12, 2016 21:28
-
-
Save davidallsopp/cc15ef3c4c32dec3778f to your computer and use it in GitHub Desktop.
Recursively find files from a starting directory, as a 1-line dictionary comprehension (or you could use a generator comprehension). Can easily add a filter using an "if" clause in the comprehension
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> import os | |
>>> from os.path import join | |
>>> [join(dr,f) for dr, dirs, files in os.walk('test') for f in files if f.endswith('html')] | |
['test/t1.html', 'test/t2.html', 'test/subtest/t3', 'test/subtest/subsubtest/t6.html'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment