Skip to content

Instantly share code, notes, and snippets.

@kushaagr
Last active March 23, 2025 16:14
Show Gist options
  • Save kushaagr/9741809afb10c01e3955b48d27ea3a5a to your computer and use it in GitHub Desktop.
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
# 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