Last active
November 30, 2019 09:24
-
-
Save zhanglintc/c9b112a915316b3805fa to your computer and use it in GitHub Desktop.
yield each file's path in a given folder
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import os | |
def each_file(target): | |
for root, dirs, files in os.walk(target): | |
for f in files: | |
yield os.path.join(root, f) | |
def each_file(t): | |
import os | |
return (os.path.join(root, f) for root, _, fs in os.walk(t) for f in fs) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment