Skip to content

Instantly share code, notes, and snippets.

@rsnemmen
Created February 27, 2018 14:54
Show Gist options
  • Select an option

  • Save rsnemmen/159144463b80ad835e1e84d236c90a05 to your computer and use it in GitHub Desktop.

Select an option

Save rsnemmen/159144463b80ad835e1e84d236c90a05 to your computer and use it in GitHub Desktop.
Given a PATH or PYTHONPATH environment variable, find the full path of a file among different options
# Obtained from https://stackoverflow.com/a/1124851/793218
#
for p in os.environ["PYTHONPATH"].split(":"):
for r,d,f in os.walk(p):
for files in f:
if files == "filename.extension":
print(os.path.join(r,files))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment