Created
November 25, 2012 17:34
-
-
Save yann2192/4144475 to your computer and use it in GitHub Desktop.
Find a file in subdir
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 | |
def findInSubdirectory(filename, subdirectory=''): | |
if subdirectory: | |
path = subdirectory | |
else: | |
path = os.getcwd() | |
for root, dirs, names in os.walk(path): | |
if filename in names: | |
return os.path.join(root, filename) | |
raise 'File not found' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment