I want to change a user's current working directory when they run a Python script. For example, if I have the following script called chdir.py
:
import os
os.chdir('Desktop')
I want to be able to do this:
$ pwd
/Users/me
$ python chdir.py
$ pwd
/Users/me/Desktop
I know that os.chdir(path)
changes the working directory during the runtime, but it resets when the script exits. Is there any way to prevent this?