Created
October 17, 2022 07:38
-
-
Save berkorbay/d45068d631cd7d8e22735ac99ebbc993 to your computer and use it in GitHub Desktop.
Getting to upper directories in Python
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
### This gist gives you the code snippet to reach upper directories | |
### so you can reach other functions in the document | |
### e.g. from mainfolder.subfolder.subfolder.examplefile import example_function | |
#### Include upper dirs start | |
dpath = os.path.dirname(os.path.abspath(__file__)) | |
for i in range(4): | |
dpath = os.path.dirname(dpath) | |
sys.path.insert(1, dpath) | |
#### Include upper dirs end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment