Last active
March 14, 2024 09:59
-
-
Save izikeros/74737eecacd95c89c5eaf4791fb72581 to your computer and use it in GitHub Desktop.
[get python project root] #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
| # if this file is located in e.g. | |
| # my_project/src/get_project_root.py | |
| # it will return absolute path to the project root e.g. | |
| # /home/john/projects/my_project | |
| # If you have different structure - play with chaining '.parrent' | |
| def get_project_root() -> Path: | |
| return Path(os.path.dirname(os.path.realpath(__file__))).parent |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment