Created
February 27, 2018 14:54
-
-
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
This file contains hidden or 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
| # 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