Last active
March 23, 2025 16:14
-
-
Save kushaagr/9741809afb10c01e3955b48d27ea3a5a to your computer and use it in GitHub Desktop.
[Change PWD to main] Set pwd in python environment to current file's location
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
# Get the absolute path of the directory containing main.py | |
script_dir = os.path.dirname(os.path.abspath(__file__)) | |
# Change the current working directory to script_dir | |
os.chdir(script_dir) | |
print("Current Working Directory:", os.getcwd()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment